コード例 #1
0
        internal PeerConnection(
            Metainfo meta,
            PeerId peerId,
            IReadOnlyList <byte> reservedBytes,
            ProtocolExtension supportedExtensions,
            IPeerMessageHandler messageHandler,
            ITransportStream transportStream)
        {
            this.messageHandler  = messageHandler;
            this.transportStream = transportStream;
            customValues         = new Dictionary <IModule, Dictionary <string, object> >();
            PeerId                = peerId;
            ReservedBytes         = reservedBytes;
            SupportedExtensions   = supportedExtensions;
            InfoHash              = meta.InfoHash;
            reader                = new BigEndianBinaryReader(transportStream.Stream);
            writer                = new BigEndianBinaryWriter(transportStream.Stream);
            Available             = new Bitfield(meta.Pieces.Count);
            RequestedByRemotePeer = new HashSet <BlockRequest>();
            Requested             = new HashSet <BlockRequest>();

            IsRemotePeerInterested   = false;
            IsInterestedInRemotePeer = false;
            IsChokedByRemotePeer     = true;
            IsChokingRemotePeer      = true;
        }
コード例 #2
0
        protected virtual void Start()
        {
            //This just validates that the handler was created
            if (Handler == null)
            {
                ThrowFailedInitialization();
                return;
            }

            IPeerMessageHandler <TIncomingPayloadBaseType, TOutgoingPayloadType> handler = null;

            try
            {
                handler = Handler.Value;
            }
            catch (Exception e)
            {
                ThrowFailedInitialization(e);
                throw;
            }

            if (handler == null)
            {
                ThrowFailedInitialization();
                return;
            }
        }
コード例 #3
0
 public PeerConnectionArgs(
     PeerId localPeerId,
     Metainfo metainfo,
     IPeerMessageHandler messageHandler)
 {
     LocalPeerId    = localPeerId;
     Metainfo       = metainfo;
     MessageHandler = messageHandler;
 }
コード例 #4
0
 public QueueingMessageHandler(IMainLoop mainLoop, IPeerMessageHandler underlying)
 {
     this.mainLoop   = mainLoop;
     this.underlying = underlying;
 }
コード例 #5
0
 public QueueingMessageHandler(IMainLoop mainLoop, IPeerMessageHandler underlying)
 {
     _mainLoop   = mainLoop ?? throw new ArgumentNullException(nameof(mainLoop));
     _underlying = underlying ?? throw new ArgumentNullException(nameof(underlying));
 }