Ejemplo n.º 1
0
        private void _SimpleParser(object sender, ReadLineEventArgs args)
        {
            string rawline = args.Line;

            string[] rawlineex   = rawline.Split(new char[] { ' ' });
            string   messagecode = "";

            if (rawline[0] == ':')
            {
                messagecode = rawlineex[1];

                ReplyCode replycode = ReplyCode.Null;
                try {
                    replycode = (ReplyCode)int.Parse(messagecode);
                } catch (FormatException) {
                }

                if (replycode != ReplyCode.Null)
                {
                    switch (replycode)
                    {
                    case ReplyCode.Welcome:
                        _IsRegistered = true;
#if LOG4NET
                        Logger.Connection.Info("logged in");
#endif
                        break;
                    }
                }
                else
                {
                    switch (rawlineex[1])
                    {
                    case "PONG":
                        DateTime now = DateTime.Now;
                        _LastPongReceived = now;
                        _Lag = now - _LastPingSent;

#if LOG4NET
                        Logger.Connection.Debug("PONG received, took: " + _Lag.TotalMilliseconds + " ms");
#endif
                        break;
                    }
                }
            }
            else
            {
                messagecode = rawlineex[0];
                switch (messagecode)
                {
                case "ERROR":
                    IsConnectionError = true;
                    break;
                }
            }
        }
Ejemplo n.º 2
0
        private void _SimpleParser(object sender, ReadLineEventArgs args)
        {
            string   rawline = args.Line;
            string[] rawlineex = rawline.Split(new char[] {' '});
            string   messagecode = "";

            if (rawline[0] == ':') {
                messagecode = rawlineex[1];

                ReplyCode replycode = ReplyCode.Null;
                try {
                    replycode = (ReplyCode)int.Parse(messagecode);
                } catch (FormatException) {
                }

                if (replycode != ReplyCode.Null) {
                    switch (replycode) {
                        case ReplyCode.Welcome:
                            _IsRegistered = true;
            #if LOG4NET
                            Logger.Connection.Info("logged in");
            #endif
                            break;
                    }
                } else {
                    switch (rawlineex[1]) {
                        case "PONG":
                            DateTime now = DateTime.Now;
                            _LastPongReceived = now;
                            _Lag = now - _LastPingSent;

            #if LOG4NET
                            Logger.Connection.Debug("PONG received, took: "+_Lag.TotalMilliseconds+" ms");
            #endif
                            break;
                    }
                }
            } else {
                messagecode = rawlineex[0];
                switch (messagecode) {
                    case "ERROR":
                        IsConnectionError = true;
                    break;
                }
            }
        }
Ejemplo n.º 3
0
 private void irc_OnReadLine(object sender, ReadLineEventArgs e)
 {
     //this.AddChatMsg(e.Line);
 }
Ejemplo n.º 4
0
 private void _Worker(object sender, ReadLineEventArgs e)
 {
     // lets see if we have events or internal messagehandler for it
     _HandleEvents(MessageParser(e.Line));
 }