Team XSockets.NET

What is IMessage?

In the previous section (Your first controller) you could see that the OnMessage method had a parameter of type IMessage.

The signature of IMessage looks like this

The IMessage is the internal message format of XSockets and there are several important reasons it's existence.

It makes cross-protocol communication possible

One of the responsibilities of a protocol module is to convert each incoming frame to a IMessage. Since all incoming data is transformed into the common IMessage format we can have the same logic for all clients regardless of protocol.

It tells XSockets what controller and method to invoke

Since the IMessage has Topic and Controller as properties the framework can route each message to the correct Controller and method (where method name is matched against the topic). The value in the Data will then be serialized into the parameter(s) of the method.

Enables model binding

Since XSockets reflects all modules and methods at startup the Data part of an IMessage can be serialized into the types that your method expects. When you do not know (or do not care) about the parameter type you can use IMessage as the type instead.

results matching ""

    No results matching ""