示例#1
0
        private void ConnectAnnounceCallback(IAsyncResult ar)
        {
            ConnectAnnounceState announceState = (ConnectAnnounceState)ar;

            try
            {
                if (announceState.SavedException != null)
                {
                    FailureMessage = announceState.SavedException.Message;
                    amConnecting   = false;
                    DoAnnounceComplete(false, announceState.AsyncState, new List <Peer>());
                    return;
                }
                if (!ConnectCallback(ar))//bad transaction id
                {
                    DoAnnounceComplete(false, announceState.AsyncState, new List <Peer>());
                    return;
                }
                DoAnnounce(announceState.Parameters, announceState.AsyncState);
            }
            catch
            {
                DoAnnounceComplete(false, announceState.AsyncState, null);
            }
        }
示例#2
0
        private void AnnounceCallback(IAsyncResult ar)
        {
            ConnectAnnounceState announceState = (ConnectAnnounceState)ar;

            try
            {
                if (announceState.SavedException != null)
                {
                    FailureMessage = announceState.SavedException.Message;
                    DoAnnounceComplete(false, announceState.AsyncState, new List <Peer>());
                    return;
                }
                UdpTrackerMessage rsp = Receive(announceState, announceState.Data);
                if (!(rsp is AnnounceResponseMessage))
                {
                    DoAnnounceComplete(false, announceState.AsyncState, new List <Peer>());
                    return;
                }

                MinUpdateInterval = ((AnnounceResponseMessage)rsp).Interval;
                CompleteAnnounce(rsp, announceState.AsyncState);
            }
            catch
            {
                DoAnnounceComplete(false, announceState.AsyncState, null);
            }
        }
 private void DoAnnounce(AnnounceParameters parameters, object state)
 {
     var announceState = new ConnectAnnounceState(parameters, AnnounceCallback, state);
     announceState.Message = new AnnounceMessage(DateTime.Now.GetHashCode(), connectionId, parameters);
     try
     {
         SendAndReceive(announceState);
     }
     catch (SocketException)
     {
         DoAnnounceComplete(false, state, new List<Peer>());
     }
 }
示例#4
0
        private void DoAnnounce(AnnounceParameters parameters, object state)
        {
            ConnectAnnounceState announceState = new ConnectAnnounceState(parameters, AnnounceCallback, state);

            announceState.Message = new AnnounceMessage(DateTime.Now.GetHashCode(), connectionId, parameters);
            try
            {
                SendAndReceive(announceState);
            }
            catch (SocketException)
            {
                DoAnnounceComplete(false, state, new List <Peer>());
            }
        }