public static void EnqueueSendMessage(IConnection connection, IEncryption encryptor, PeerMessage message, IRateLimiter rateLimiter, ConnectionMonitor peerMonitor, ConnectionMonitor managerMonitor, AsyncIOCallback callback, object state) { int count = message.ByteLength; var buffer = ClientEngine.BufferManager.GetBuffer (count); message.Encode (buffer, 0); encryptor.Encrypt (buffer, 0, count); var data = sendCache.Dequeue ().Initialise (buffer, callback, state); NetworkIO.EnqueueSend (connection, buffer, 0, count, rateLimiter, peerMonitor, managerMonitor, EndSendCallback, data); }
private void SendMessage(PeerMessage message, CustomConnection connection) { byte[] b = message.Encode(); encryptor.Encrypt(b); IAsyncResult result = connection.BeginSend(b, 0, b.Length, null, null); if (!result.AsyncWaitHandle.WaitOne(5000, true)) throw new Exception("Message didn't send correctly"); connection.EndSend(result); }
public MessageBundle(PeerMessage message) : this() { _messages.Add(message); }
void SendMessage(PeerMessage message, CustomConnection connection) { byte[] b = message.Encode(); encryptor.Encrypt(b); Send (connection, b, 0, b.Length); }