public static void SendMessageToClient(NetWriter _writer, int channelType, int clientId) { writer.StopWriting(); int writtenSize = _writer.GetWrittenBytes(); byte[] rawData = _writer.GetRawData(); NetworkCore.singleton.SendRawToClient(clientId, channelType, rawData, writtenSize); }
public static void SendMessageToServer(NetWriter _writer, int channelType) { writer.StopWriting(); if (NetworkCore.clientStatus != ConnectionStatus.Connected) { return; } int writtenSize = _writer.GetWrittenBytes(); byte[] rawData = _writer.GetRawData(); NetworkCore.singleton.SendRawToServer(channelType, rawData, writtenSize); }
/// <summary> /// Sends the message to all clients that meet the filters criteria. /// Messages sent in this way cannot be buffered into a queue /// </summary> /// <param name="_writer"></param> /// <param name="channelType"></param> /// <param name="addToBuffer"> add this message to the buffer</param> /// <returns>The Buffered Message if one was added.</returns> public static void SendMessageToFilteredClients(NetWriter _writer, int channelType, NetworkFilter filter) { writer.StopWriting(); if (!NetworkCore.isServer) { Debug.LogError("Tried to send message to filtered clients, but we are not a server!"); return; } int writtenSize = _writer.GetWrittenBytes(); byte[] rawData = _writer.GetRawData(); NetworkCore.singleton.SendRawToFilteredClients(channelType, rawData, writtenSize, filter); }
/// <summary> /// Sends the message to all clients except our local one. /// /// Messages sent in this way can be buffered into a queue, so that they are executed on all new clients in order. /// </summary> /// <param name="_writer">Writer.</param> /// <param name="channelType">Channel type.</param> /// <param name="addToBuffer"> add this message to the buffer</param> /// <returns>The Buffered Message if one was added.</returns> public static BufferedMessage SendMessageToOtherClients(NetWriter _writer, int channelType, bool addToBuffer) { writer.StopWriting(); if (!NetworkCore.isServer) { Debug.LogError("Tried to send message to other clients, but we are not a server!"); return(null); } int writtenSize = _writer.GetWrittenBytes(); byte[] rawData = _writer.GetRawData(); NetworkCore.singleton.SendRawToOtherClients(channelType, rawData, writtenSize); if (addToBuffer) { BufferedMessage msg = new BufferedMessage(channelType, (byte[])rawData.Clone(), writtenSize, false); bufferedMessages.Add(msg); return(msg); } return(null); }