Diarkis Inc.

Top > Blog > Implementing RPC Without Server

Implementing RPC Without Server

Diarkis C# client offers RPC class to help you implement client-to-client RPC without having to code server-side logic at all.

What Is RPC?

An RPC – Remote Procedure Call is a technique that allows remote computers to invoke and execute computational operations as if it were a normal procedure. Typically used for client-to-server-based applications.

Why Is This Useful?

With Diarkis RPC, you may implement features that require remote computing without adding server logic at all. In some cases, you might not have access to the server or you simply do not have server-side engineers. The ability to complete remote computing features with the client-side only could be useful.

Implementation Example

Diarkis RPC class uses the Room module as its communication broker for RPC.

How To Set Up RPC Class

Diarkis.Modules.RPC rpc = new Diarkis.Modules.RPC(room);

RCP class requires an instance of Room class. For details on the Room class, please read here.

How To Register An RPC method

In order to execute specific RPC logic, you must “register” methods that implement RPC logic.

// rpcID is used to call the associated method HelloWorld
int rpcID = 1;
bool registered = rpc.Register(rpcID, HelloWorld);

private void HelloWorld(byte[] msg)
    // Do something amazing here

How To Invoke An RPC

The example below will invoke an RPC on all clients:

// For UDP client, reliable true means RUDP transmission
bool reliable = true;
bool called = rpc.RPCAll(rpcID, Encoding.UTF8.GetBytes("Hello World"), reliable);

The example below will invoke an RPC on selected clients:

List<string> clientIDs = new List<string>();
// For UDP client, reliable true means RUDP transmission
bool reliable = true;
bool called = rpc.RPCMany(rpcID, clientIDs, Encoding.UTF8.GetBytes("Hello World"), reliable);

NOTE: The returned value bool “called” indicates the RPC has been called, but it does not mean the remote client has received the call and executed the call.

Diarkis enables massive multiplayer network communications.

Contact Us


If you are interested in learning more about Diarkis, please contact us here.

Contact Us Request Documents