hlwNetwork How to use.

How to send and handle basic messages.

(Not yet implemented: Possibility to await for client/server to be ready. As of now, just await a small delay to make sure it is)

The static Debug.Logger event will let you be able to print messages such as new connections to server, disconnections, etc...

Create a NetMessageHandler for the "NetMessage" class. The NetMessage class is a very simple class containing a snowflake (unique ID) and and string content. It is perfect for sendings basic logs.

In your new NetMessageHandler<NetMessage> classe, override the methods with the generic type parameter as parameters. (Here, it is NetMessage).

There is two methods, one method that will be used by the server, and one by the client. If your program uses only the client or server part, or if a particular request goes only one way, you only need to Handle one of the two.

Use the server or client (or both) constructors, then add the MessageHandler to them.

Make them run Asynchronously. (Don't await for them, it will never return unless the connection is closed).

await for them to be ready, and use the "Send(INetMessage message)" method to send a message from the client to the server.

(By using the "Send(string message) method, a "NetMessage" will be created with the message as content, then sent).

For each clientSide client, there is a ServerSide client. Use the serverside client to send a message back to the clientSide client.

Another example.