Ejemplo n.º 1
0
 protected virtual void TriggerOnSend(SendMessageEventArgs e)
 {
     if (this.OnSend != null)
     {
         this.OnSend(this, e);
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Send a message to the connected server.
        /// </summary>
        /// <param name="message">The NetIRC.SendMessage instance to be sent.</param>
        public void Send(Messages.ISendMessage message)
        {
            SendMessageEventArgs e = new SendMessageEventArgs(message);

            this.TriggerOnSend(e);
            if (e.Message == null)
            {
                return;
            }

            using (MemoryStream stream = new MemoryStream())
            {
                message.Send(new StreamWriter(stream)
                {
                    AutoFlush = true
                }, this);

                StreamReader reader = new StreamReader(stream);
                stream.Position = 0;

                while (true)
                {
                    string line = reader.ReadLine();

                    if (string.IsNullOrEmpty(line))
                    {
                        break;
                    }

                    foreach (Type writerType in this._outputWriters)
                    {
                        IWriter instance = (IWriter)Activator.CreateInstance(writerType);
                        instance.ProcessSendMessage(line, this);
                    }
                }
            }
        }
Ejemplo n.º 3
0
 protected virtual void TriggerOnSend(SendMessageEventArgs e)
 {
     if (this.OnSend != null)
     {
         this.OnSend(this, e);
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Send a message to the connected server.
        /// </summary>
        /// <param name="message">The NetIRC.SendMessage instance to be sent.</param>
        public void Send(Messages.ISendMessage message)
        {
            SendMessageEventArgs e = new SendMessageEventArgs(message);
            this.TriggerOnSend(e);
            if (e.Message == null) return;

            using (MemoryStream stream = new MemoryStream())
            {
                message.Send(new StreamWriter(stream) {AutoFlush = true}, this);

                StreamReader reader = new StreamReader(stream);
                stream.Position = 0;

                while (true)
                {
                    string line = reader.ReadLine();

                    if (string.IsNullOrEmpty(line))
                    {
                        break;
                    }

                    foreach (Type writerType in this._outputWriters)
                    {
                        IWriter instance = (IWriter)Activator.CreateInstance(writerType);
                        instance.ProcessSendMessage(line, this);
                    }
                }
            }
        }