Beispiel #1
0
 /// <summary>
 /// Raises the <see cref="MessageSending"/> event.
 /// </summary>
 protected void OnMessageSending(CancelIrcMessageEventArgs<IrcMessage> e)
 {
     var handler = this.MessageSending;
     if (handler != null)
     {
         handler(this, e);
     }
 }
 /// <summary>
 /// Raises the MessageSending event.
 /// </summary>
 /// <param name="e"></param>
 protected void OnMessageSending( CancelIrcMessageEventArgs<IrcMessage> e )
 {
     if ( this.MessageSending != null )
     {
         this.MessageSending( this, e );
     }
 }
Beispiel #3
0
        /// <summary>
        ///   Sends a <see cref="IrcMessage" /> over a <see cref="ClientConnection" /> to an IRC server.
        /// </summary>
        /// <param name="message">The <see cref="IrcMessage" /> to send.</param>
        public virtual async Task Send(IrcMessage message)
        {
            if (message == null)
            {
                return;
            }

            var e = new CancelIrcMessageEventArgs<IrcMessage>(message);
            this.OnMessageSending(e);
            if (e.Cancel)
            {
                return;
            }

            message.Validate(this.ServerSupports);
            await this.Connection.Write(message + Environment.NewLine);
        }
        /// <summary>
        /// Sends a <see cref="IrcMessage"/> over a <see cref="ClientConnection"/> to an irc server.
        /// </summary>
        /// <param name="message">The <see cref="IrcMessage"/> to send.</param>
        public virtual void Send( IrcMessage message )
        {
            if ( message == null )
            {
                return;
            }

            CancelIrcMessageEventArgs<IrcMessage> e = new CancelIrcMessageEventArgs<IrcMessage>( message );
            this.OnMessageSending( e );
            if ( e.Cancel )
            {
                return;
            }

            TextWriter originalWriter = this.writer.InnerWriter;
            using ( StringWriter myInnerWriter = new StringWriter( CultureInfo.InvariantCulture ) )
            {
                this.writer.InnerWriter = myInnerWriter;

                message.Validate( this.ServerSupports );
                message.Format( writer );
                this.Connection.Write( myInnerWriter.ToString() );

                this.writer.InnerWriter = originalWriter;
            }
        }