Inspirel banner

Programming Distributed Systems with YAMI4

6.2.4 .NET

In C# the message handler can be given as a delegate with the signature defined by Agent.IncomingMessageHandler.

An example message handler can be implemented in the following way:

using Inspirel.YAMI;

// ...
class MyServer
{
    static void ProcessMessage(
        object sender, IncomingMessageArgs message)
    {
        // code processing the incoming message
        // ...
    }
}

and the registration, from some context where the above function is visible, can look like:

myAgent.RegisterObject("my_object",
    new Agent.IncomingMessageHandler(ProcessMessage));

// or simply:

myAgent.RegisterObject("my_object", ProcessMessage);