Esempio n. 1
0
        public static void EnqueueReceiveMessage(IConnection connection, IEncryption decryptor, IRateLimiter rateLimiter, ConnectionMonitor monitor, TorrentManager manager, AsyncMessageReceivedCallback callback, object state)
        {
            // FIXME: Hardcoded number
            int count  = 4;
            var buffer = ClientEngine.BufferManager.GetBuffer(count);
            var data   = receiveCache.Dequeue().Initialise(connection, decryptor, rateLimiter, monitor, manager, buffer, callback, state);

            NetworkIO.EnqueueReceive(connection, buffer, 0, count, rateLimiter, monitor, data.ManagerMonitor, MessageLengthReceivedCallback, data);
        }
Esempio n. 2
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);
        }