Single Message Sharing

Apart from the whole State Sharing in Room System, there is another independent system that you can work with.

Sometimes we don't need to constantly share our state with everyone. We just need to send a single 'message' from one Client to another.

For example..

  1. Sending a chat message to the players in your room

  2. Telling one player to reduce their health by 10

That can be done using the SendMessageToClient() function which takes the reciever's clientId and the message you want to send as a string.

An even better Function: SendEventToClient()

The SendEventToClient function not only takes a single string message but takes an event name like "chat_message" and a full message struct like { text: "hello, my name is shake" senderName : "lilshake" }

In turn based multiplayer games, the state sharing system is less useful and this system is more useful.

Last updated