/// <summary> /// Sends binary message to all clients ignoring the specific one /// </summary> /// <param name="receivers">The clients / server to receive the message</param> /// <param name="playerToIgnore"></param> /// <param name="messageGroupId">The Binary.GroupId of the massage, use MessageGroupIds.START_OF_GENERIC_IDS + desired_id</param> /// <param name="reliable">True if message must be delivered</param> /// <param name="objectsToSend">Array of vars to be sent, read them with Binary.StreamData.GetBasicType<typeOfObject>()</param> /// <summary> ///向所有客户发送二进制消息,忽略特定的消息 /// </ summary> /// <param name =“receivers”>接收消息的客户机/服务器</ param> /// <param name =“playerToIgnore”> </ param> /// <param name =“messageGroupId”>按摩的Binary.GroupId,使用MessageGroupIds.START_OF_GENERIC_IDS + desired_id </ param> /// <param name =“reliable”>如果消息必须被传递,则为真</ param> /// <param name =“objectsToSend”>要发送的变量数组,使用Binary.StreamData.GetBasicType <typeOfObject>()</ param> public virtual void Send(Receivers receivers = Receivers.Target, NetworkingPlayer playerToIgnore = null, int messageGroupId = MessageGroupIds.START_OF_GENERIC_IDS, bool reliable = false, params object[] objectsToSend) { BMSByte data = ObjectMapper.BMSByte(objectsToSend); Binary sendFrame = new Binary(Time.Timestep, false, data, receivers, messageGroupId, false); Send(sendFrame, reliable, playerToIgnore); }
/// <summary> /// Sends binary message to the specific receiver(s) /// </summary> /// <param name="receivers">The clients / server to receive the message</param> /// <param name="messageGroupId">The Binary.GroupId of the massage, use MessageGroupIds.START_OF_GENERIC_IDS + desired_id</param> /// <param name="objectsToSend">Array of vars to be sent, read them with Binary.StreamData.GetBasicType<typeOfObject>()</param> public virtual void Send(Receivers receivers, int messageGroupId, params object[] objectsToSend) { BMSByte data = ObjectMapper.BMSByte(objectsToSend); Binary sendFrame = new Binary(Time.Timestep, true, data, receivers, messageGroupId, true); Send(sendFrame); }
/// <summary> /// Sends binary message to the specific client /// </summary> /// <param name="receivers">The clients / server to receive the message</param> /// <param name="messageGroupId">The Binary.GroupId of the massage, use MessageGroupIds.START_OF_GENERIC_IDS + desired_id</param> /// <param name="targetPlayer">The client to receive the message</param> /// <param name="objectsToSend">Array of vars to be sent, read them with Binary.StreamData.GetBasicType<typeOfObject>()</param> public void SendToPlayer(NetworkingPlayer targetPlayer, Receivers receivers = Receivers.Target, int messageGroupId = MessageGroupIds.START_OF_GENERIC_IDS, params object[] objectsToSend) { BMSByte data = ObjectMapper.BMSByte(objectsToSend); Binary sendFrame = new Binary(Time.Timestep, false, data, receivers, messageGroupId, false); SendToPlayer(sendFrame, targetPlayer); }
/// <summary> /// Goes through all of the currently connected players and send them the frame /// </summary> /// <param name="receivers">The clients / server to receive the message</param> /// <param name="messageGroupId">The Binary.GroupId of the massage, use MessageGroupIds.START_OF_GENERIC_IDS + desired_id</param> /// <param name="playerToIgnore">The client to ignore</param> /// <param name="objectsToSend">Array of vars to be sent, read them with Binary.StreamData.GetBasicType<typeOfObject>()</param> public void SendAll(Receivers receivers = Receivers.All, int messageGroupId = MessageGroupIds.START_OF_GENERIC_IDS, NetworkingPlayer playerToIgnore = null, params object[] objectsToSend) { BMSByte data = ObjectMapper.BMSByte(objectsToSend); Binary sendFrame = new Binary(Time.Timestep, false, data, receivers, messageGroupId, true); SendAll(sendFrame, playerToIgnore); }
/// <summary> /// Sends binary message to the specific tcp client(s) /// </summary> /// <param name="client">The client to receive the message</param> /// <param name="receivers">Receiver's type</param> /// <param name="messageGroupId">The Binary.GroupId of the massage, use MessageGroupIds.START_OF_GENERIC_IDS + desired_id</param> /// <param name="objectsToSend">Array of vars to be sent, read them with Binary.StreamData.GetBasicType<typeOfObject>()</param> public bool Send(TcpClient client, Receivers receivers = Receivers.Target, int messageGroupId = MessageGroupIds.START_OF_GENERIC_IDS, params object[] objectsToSend) { BMSByte data = ObjectMapper.BMSByte(objectsToSend); Binary sendFrame = new Binary(Time.Timestep, false, data, Receivers.Target, messageGroupId, false); return(Send(client, sendFrame)); }