/// <summary> /// Sends a custom message created by the server to all connected clients, optionally excluding one client. /// The 'except' client may be null to send to all. /// </summary> public static NetSendResult SendCustomMessageToAll(NetConnection except, NetOutgoingMessage msg, NetDeliveryMethod delivery = NetDeliveryMethod.ReliableOrdered, int sequenceChannel = 31) { if (!IsServer) { Error("Server not running, cannot send custom message."); return(NetSendResult.FailedNotConnected); } if (msg == null) { Error("Null custom message."); return(NetSendResult.Dropped); } if (except == null) { Server.SendToAll(msg, delivery, sequenceChannel); return(NetSendResult.Sent); } else { Server.SendToAllExcept(except, msg, delivery, sequenceChannel); return(NetSendResult.Sent); } }
public void SerializeAll() { if (!JNet.IsServer) { JNet.Error("Not on server, cannot serialize all."); return; } for (int i = 0; i < ActiveObjects.Count; i++) { var obj = ActiveObjects[i]; if(obj == null) { JNet.Error("Null object in tracked objects list."); ActiveObjects.RemoveAt(i); i--; continue; } if(obj.NetBehaviours != null) { foreach (var b in obj.NetBehaviours) { if(b != null && b.NetDirty) { JNetServer server = JNet.GetServer(); NetOutgoingMessage msg = server.CreateMessage(); msg.Write((byte)JDataType.SERIALIZED); msg.Write(obj.NetID); msg.Write(b.BehaviourID); b.NetSerialize(msg, false); server.SendToAllExcept(server.LocalClientConnection, msg, b.SerializationDeliveryMethod, 1); b.NetDirty = false; } } } } }