Esempio n. 1
0
        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);
        }
Esempio n. 2
0
 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);
 }
Esempio n. 3
0
 void SendMessage(PeerMessage message, CustomConnection connection)
 {
     byte[] b = message.Encode();
     encryptor.Encrypt(b);
     Send (connection, b, 0, b.Length);
 }
Esempio n. 4
0
 public MessageBundle(PeerMessage message)
     : this()
 {
     _messages.Add(message);
 }