You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Chat example is not very complex. There are no private messages or channels. It builds on the SimpleConnection example by adding InsightModules for message handling.
Sending a chat message to the server:
publicvoidHandleSendChat(){insight.Send((short)MsgId.Chat,newChatMsg(){Origin=nameInput.text,Data=chatInput.text});chatInput.text="";//Clear out the previously entered text from the field}
Once the server receives the message it simply echoes it back to all the connected clients:
privatevoidHandleChatMsg(InsightNetworkMessagenetMsg){if(server.logNetworkMessages){Debug.Log("[InsightServer] - HandleChatMsg()");}ChatMsgmessage=netMsg.ReadMessage<ChatMsg>();server.SendToAll((short)MsgId.Chat,message);//Broadcast back to all other clients}