MultiConnectSDK › AI Agent Guide
5. Messages
- Mark every class you send with
[McSerializationObject]: it registers the class when the SDK starts. Give it a parameterless constructor so its fields' initial values apply. - Public fields, and properties with a getter and a setter, are sent. Use
[McSerializationIgnore]to leave one out. - Client and server use the same class name in the same namespace. Members are matched by name, so a client and a server built with different versions of a class still read each other: an added member keeps its initial value on the side that lacks it in the message, and a removed one is ignored. Rename a member with
[McFormerName("oldName")]. Add new message types to the shared file. - On the server, take the sender from a listener with two parameters,
(string senderId, object message): MultiConnectSDK fillssenderIdfrom the connection. Never trust a player id written inside the message. - Supported: every number type,
bool,char,string, enums,DateTime,TimeSpan,Guid,T?, arrays,T[,],List<T>,HashSet<T>,Dictionary<K,V>andConcurrentDictionary<K,V>with any key, and your own classes and structs. Not sent: members typedobject, an interface or an abstract class. McProtocol.Reliablealways arrives, in order. Use it for anything that matters.McProtocol.Unreliableis for frequent updates, such as positions, and needs Use UDP on both server and client. Without a working unreliable path, it is sent as Reliable.- The message type is your own enum, with values of your choice.
- Send only what is needed. The server must check everything a client sends, because a client can be modified.

