Esempio n. 1
0
 private static void HandleConnectionDisconnected(object sender, ConnectionDataEventArgs e)
 {
     Ident.Service.Stop();
 }
        /// <summary>
        ///   Raises the <see cref="DccServerConnection.Disconnected" /> event of the
        ///   <see cref="DccServerConnection" /> object.
        /// </summary>
        protected virtual void OnDisconnected(ConnectionDataEventArgs e)
        {
            if (this.SynchronizationObject != null && this.SynchronizationObject.InvokeRequired)
            {
                Action del = () => this.OnDisconnected(e);
                this.SynchronizationObject.Invoke(del, null);
                return;
            }

            if (this.Disconnected != null)
            {
                this.Disconnected(this, e);
            }
        }
Esempio n. 3
0
        /// <summary>
        ///   Transforms <see cref="ClientConnection" /> data into raised <see cref="IrcMessage" /> events.
        /// </summary>
        private void HandleConnectionDataReceived(object sender, ConnectionDataEventArgs e)
        {
            IrcMessage msg;
            try
            {
                msg = IrcMessageFactory.Parse(e.Data);
            }
            catch (InvalidMessageException ex)
            {
                // try one more time to parse it as a generic message
                msg = new GenericMessage();
                if (msg.CanParse(e.Data))
                {
                    msg.Parse(e.Data);
                }
                else
                {
                    msg = null;
                    Trace.WriteLine(ex.Message + " { " + ex.ReceivedMessage + " } ", "Invalid Message");
                }
            }

            if (msg != null)
            {
                this.OnMessageParsed(new IrcMessageEventArgs<IrcMessage>(msg));
                msg.Notify(this.Messages);
            }
        }