public void SendBytes(byte[] bytes, string recipientID, string senderID) { if (socketOut.Connected) { LastMessage = DateTime.Now; if (Encryptor != null) { bytes = Encryptor.EncryptBytes(bytes); } var messageHeader = new byte[] { (byte)(bytes.Length % 10000000000 / 100000000), (byte)(bytes.Length % 100000000 / 1000000), (byte)(bytes.Length % 1000000 / 10000), (byte)(bytes.Length % 10000 / 100), (byte)(bytes.Length % 100), }; bytes = messageHeader.Concat(bytes).ToArray(); var socketArgs = SocketArgsPool.GetSendArg(); socketArgs.RecipientID = recipientID; socketArgs.SetBuffer(bytes, 0, bytes.Length); socketOut.SendAsync(socketArgs); } }
public void SendBytesUnencrypted(byte[] bytes) { if (socketOut.Connected) { var messageHeader = new byte[] { (byte)(bytes.Length % 10000000000 / 100000000), (byte)(bytes.Length % 100000000 / 1000000), (byte)(bytes.Length % 1000000 / 10000), (byte)(bytes.Length % 10000 / 100), (byte)(bytes.Length % 100), }; bytes = messageHeader.Concat(bytes).ToArray(); var socketArgs = SocketArgsPool.GetSendArg(); socketArgs.SetBuffer(bytes, 0, bytes.Length); socketOut.SendAsync(socketArgs); } }