Ejemplo n.º 1
0
        private void iDisconnected(object sender, WorkArgs e)
        {
            iSocket      = null;
            SocketStatus = NNTPStatus.Closed;

            //Debug.WriteLine("iDisconnected: " + e.Message);

            try
            {
                if ((e != null) && (Failed != null))
                {
                    Failed(e.Code, e.Message, iServer.Log, this);
                }
            }
            catch { }

            if (Closed != null)
            {
                Closed(this);
            }
        }
Ejemplo n.º 2
0
        private void iReceived(object sender, WorkArgs e)
        {
            string sBOF = "";
            string sEOF = "";

            byte lBOFLength = 3;
            byte lEOFLength = 5;

            bool bFinished = false;

            try
            {
                if (SocketStatus != NNTPStatus.Multiline)
                {
                    if (e.Data.Length >= lBOFLength)
                    {
                        sBOF = Common.GetBOF(e.Data, lBOFLength);

                        StatusCode = Common.GetCode(sBOF);

                        switch (StatusCode)
                        {
                        case (int)NNTPCodes.GroupsFollow:
                        case (int)NNTPCodes.XINDEXFollows:
                        case (int)NNTPCodes.ArticleFollows:
                        case (int)NNTPCodes.HeadFollows:
                        case (int)NNTPCodes.BodyFollows:
                        case (int)NNTPCodes.StatFollows:
                        case (int)NNTPCodes.XOVERFollows:
                        case (int)NNTPCodes.NewNewsFollows:
                        case (int)NNTPCodes.XGTITLEFollows:
                        case (int)NNTPCodes.XTHREADFollows:

                            SocketStatus = NNTPStatus.Multiline;
                            break;
                        }
                    }
                }

                int lPos = Convert.ToInt32(e.Data.Length - lEOFLength);

                if (lPos >= 0)
                {
                    sEOF = Common.GetEOF(e.Data, lEOFLength);

                    switch (SocketStatus)
                    {
                    case NNTPStatus.Multiline:

                        bFinished = (sEOF == (Environment.NewLine + "." + Environment.NewLine));
                        break;

                    default:

                        bFinished = (Common.VbRight(sEOF, 2) == Environment.NewLine);
                        break;
                    }
                }

                if (!bFinished)
                {
                    Receive();
                    return;
                }

                e.Data.Seek(0, SeekOrigin.Begin);
                Process(StatusCode, e.Data);
            }
            catch (Exception ex)
            {
                Disconnect(992, "Received: " + ex.Message, false);
            }
        }
Ejemplo n.º 3
0
 private void iConnected(object sender, WorkArgs e)
 {
     Receive();
 }
Ejemplo n.º 4
0
 private void SafeFire(EventHandler<WorkArgs> Ev, WorkArgs Args)
 {
     EventHandler<WorkArgs> tmp = Ev;
     if (tmp != null) { tmp(this, Args); }
 }