public void Broadcast(byte[] data) { var packedData = SoketinUtility.PackRawData(data); foreach (var client in m_clients) { Send(client, packedData); } }
public void Send(byte[] data) { if (m_stopSignal) { return; } var packedData = SoketinUtility.PackRawData(data); m_socket.BeginSend(packedData, 0, packedData.Length, 0, new AsyncCallback(_onBeginSend), m_socket); }
//Write Function #region Write Function public void WriteString(string value, bool compressed = false) { if (string.IsNullOrEmpty(value)) { throw new ArgumentNullException("Value Cannot Be Null"); } byte[] strData = compressed ? SoketinUtility.ZipString(value) : SoketinUtility.StringToBytes(value); byte[] packedData = SoketinUtility.PackRawData(strData); m_stream.Write(packedData, 0, packedData.Length); }
public void Send(SoketinUser client, byte[] data) { var user = m_clients.Find((c) => { return(c._socket == client._socket); }); if (user != null) { var packedData = SoketinUtility.PackRawData(data); client._socket.BeginSend(packedData, 0, packedData.Length, 0, new AsyncCallback(_onBeginSend), client); } }
public void Send(byte[] data, params SoketinUser[] addressess) { if (addressess != null && addressess.Length > 0) { var packedFile = SoketinUtility.PackRawData(data); foreach (var address in addressess) { var endPoint = new IPEndPoint(IPAddress.Parse(address._ipAddress), address._port); m_socket.BeginSendTo(packedFile, 0, packedFile.Length, 0, endPoint, new AsyncCallback(_onBeginSend), address); } } }