Git Product home page Git Product logo

csrpc's Introduction

CsRPC

A easy to use, UDP based C# RPC libary.

This libary does provide an easy way to make function calls on the remote machine using coustom parameters. This libary is experimental and not maintained.

Howto:

The Libary itself can be used with a premade Socket or only given IPEndPoint to connect to. The Intention is to have an Server <-> Client scenario.

1. Function Stack

First of all you have to define a Function Stack where all callable functions are defined.

class FStack
{
    [SERVER]
    public static bool _Init(EndPoint clientEP)
    {
        Console.WriteLine(clientEP.ToString());
        return true;
    }
    public static int inc(int num)
    {
        Console.WriteLine("NumTest");
        //Console.WriteLine(ipe.ToString());
        return ++num;
    }
}

This Function Stack has to be the same on all Clients. The name has to be unique!

The Init Function will be needed to handle all the Clients.

The Server tag is added for controlling the execution flow. Only if you have Authority you can execute Server functions.

2. Server

Next you have to define the Server.

Socket serverSo = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
serverSo.Bind(new IPEndPoint(IPAddress.Any, 20888));

net_manager server = new net_manager(serverSo, typeof(FStack), true);
server.has_authority = true;

Now you have started a new listener thread, that handles all incoming Packets.

3. Client

For the client side you have one easy call.

net_manager client = new net_manager(new IPEndPoint(IPAddress.Any, 20888), typeof(FStack), true);
client.Init();

You define wich Server you want to use, the type of the FunctionStack and if you wand to Autostart the Thread.

4. Using The Libary

Using the Libary is as easy as creating the connections. You can just do a Single line Call to execute and return Procedures.

int ret = (int)client.Execute("inc", new object[] { 5 });

The Execute function returns automatically the returned object from the remote execution. The name of the function has to be a string, this is the reason the name has to be unique. The calling parameters are bundled in a object array.

For the Server Side you have to define the Client EndPoint as Well.

int ret = (int)server.Execute("inc", new object[] { 5 }, client1.ipe);

The handling and indexing of the client EndPoints has to be done manually.

5. Handling the Clients as Server

As mentioned above you can use the _Init function as Handling function.

6. ??? ... Profit!

Use it as you like, Commercial or Free, as long as you name me as contributer.

csrpc's People

Contributors

scrapes avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.