Beispiel #1
0
 /// <summary>
 /// initializes an instance of <see cref="TmiConnection"/>
 /// </summary>
 /// <exception cref="InvalidOperationException">if invalid command handlers are defined on the used subclass</exception>
 public TmiConnection()
 {
     receiver  = new ReceiveClient(this);
     sender    = new SendClient(this);
     status    = new Status(this);
     Parser    = new TmiMessageParser();
     pingTimer = new System.Timers.Timer
     {
         AutoReset = true,
         Enabled   = false,
         Interval  = 4 * 60 * 1000
     };
     pingTimer.Elapsed += PingTimerOnElapsed;
     RegisterCommands();
 }
Beispiel #2
0
        /// <summary>
        /// IRC event: a raw message was received by us.
        /// This is where custom parsing needs to take place.
        /// </summary>
        private void Client_RawMessageReceived(object sender, IrcRawMessageEventArgs e)
        {
            TmiLog.Debug("<<<", e.RawContent);

            if (e.RawContent.StartsWith('@'))
            {
                // Looks like a TMI message with state info that we can parse & process
                var tmiMsg = TmiMessageParser.Parse(e.RawContent);

                if (tmiMsg is TmiChatMessage)
                {
                    if (OnChatMessage != null)
                    {
                        OnChatMessage.Invoke(this, new TmiChatMessageEventArgs((TmiChatMessage)tmiMsg));
                    }
                }
            }
        }