/// <summary> /// Sends a byte array to the other side. Works for all Socketers except UDP Listeners. /// If the other Socketer is not listening, the messages are lost. /// </summary> /// <param name="message">Message contents.</param> public void SendNetworkMessage(byte[] message) { if (socketer != null) { socketer.SendNetworkMessage(message); } }
/// <summary> /// Sends a byte array to the other side. Works for all Socketers except UDP Listeners. /// If the other Socketer is not listening, the messages are lost. /// </summary> /// <param name="message">Message contents.</param> public void SendNetworkMessage(byte[] message, int sourceId = 0) { if (socketer != null) { socketer.SendNetworkMessage(message, sourceId); } }
/// <summary> /// Call to send data to this endpoint /// </summary> /// <param name="data">data to send</param> public void Send(byte[] data) { if (!IsConnected) { Debug.LogWarning("Attempted to send message to disconnected SocketEndpoint."); return; } try { socketerClient.SendNetworkMessage(data, sourceId); } catch { socketerClient.Disconnect(sourceId); } }
/// <inheritdoc /> public void Send(byte[] data, long offset, long length) { if (!IsConnected) { Debug.LogWarning($"Attempted to send message to disconnected {nameof(TCPNetworkConnection)}."); } else { try { var payload = new byte[length]; Array.Copy(data, offset, payload, 0, length); socketerClient.SendNetworkMessage(payload, sourceId); } catch { socketerClient.Disconnect(sourceId); } } }
/// <inheritdoc /> public void Send(ref byte[] data) { if (!IsConnected) { Debug.LogWarning($"Attempted to send message to disconnected {nameof(TCPNetworkConnection)}."); } else { try { socketerClient.SendNetworkMessage(data, sourceId); } catch { socketerClient.Disconnect(sourceId); } } data = null; }