/// <summary> /// Syncs the given data across all clients. Use <see cref="Subscribe{T}(Action{T})"/> in order to set up receiving of certain types of messages. /// </summary> public static void Send <T>(T message) where T : class { if (message == null) { return; } var contents = JsonConvert.Serialize(message); var playerId = GetPlayerId(GetLocalPlayer()); var packets = BuildPackets(contents, playerId).ToList(); var header = new SyncHeader { PacketCount = packets.Count, PlayerId = playerId, TypeName = typeof(T).FullName }; BlzSendSyncData(SYNC_HEADER_PREFIX, JsonConvert.Serialize(header)); for (var i = 0; i < packets.Count; i++) { var text = JsonConvert.Serialize(packets[i]); BlzSendSyncData(SYNC_PACKET_PREFIX, text); } }
public SyncMessage(SyncHeader header) { SyncHeader = header; Packets = new List <SyncPacket>(); }