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);
        }
Esempio n. 3
0
 public static void EnqueueSend(IConnection connection, byte[] buffer, int offset, int count, IRateLimiter rateLimiter, ConnectionMonitor peerMonitor, ConnectionMonitor managerMonitor, AsyncIOCallback callback, object state)
 {
     var data = transferCache.Dequeue ().Initialise (connection, buffer, offset, count, callback, state, rateLimiter, peerMonitor, managerMonitor);
     lock (sendQueue)
         SendOrEnqueue (data);
 }
Esempio n. 4
0
 public AsyncIOState Initialise(IConnection connection, byte[] buffer, int offset, int count,
                         AsyncIOCallback callback,
                         object state, IRateLimiter limiter,
                         ConnectionMonitor peerMonitor, ConnectionMonitor managerMonitor)
 {
     Connection = connection;
     Buffer = buffer;
     Count = count;
     Callback = callback;
     Offset = offset;
     ManagerMonitor = managerMonitor;
     PeerMonitor = peerMonitor;
     RateLimiter = limiter;
     Remaining = count;
     State = state;
     return this;
 }
Esempio n. 5
0
        internal PeerId(Peer peer, TorrentManager manager)
        {
            if (peer == null)
                throw new ArgumentNullException("peer");

            suggestedPieces = new MonoTorrentCollection<int>();
            amChoking = true;
            isChoking = true;

            isAllowedFastPieces = new MonoTorrentCollection<int>();
            amAllowedFastPieces = new MonoTorrentCollection<int>();
            lastMessageReceived = DateTime.Now;
            lastMessageSent = DateTime.Now;
            this.peer = peer;
            maxPendingRequests = 2;
            maxSupportedPendingRequests = 50;
            monitor = new ConnectionMonitor();
            sendQueue = new MonoTorrentCollection<PeerMessage>(12);
            ExtensionSupports = new ExtensionSupports();
            TorrentManager = manager;
            InitializeTyrant();
        }
 public ReceiveMessageState Initialise(IConnection connection, IEncryption decryptor, IRateLimiter limiter, ConnectionMonitor peerMonitor, TorrentManager manager, byte[] buffer, AsyncMessageReceivedCallback callback, object state)
 {
     Connection = connection;
     Decryptor = decryptor;
     Manager = manager;
     Buffer = buffer;
     PeerMonitor = peerMonitor;
     RateLimiter = limiter;
     ManagerMonitor = manager == null ? null : manager.Monitor;
     Callback = callback;
     State = state;
     return this;
 }