Meebey.SmartIrc4net.IrcConnection._WriteLine C# (CSharp) Method

_WriteLine() private method

private _WriteLine ( string data ) : bool
data string
return bool
        private bool _WriteLine(string data)
        {
            if (IsConnected) {
                try {
                    _Writer.Write(data+"\r\n");
                    _Writer.Flush();
                } catch (IOException) {
            #if LOG4NET
                    Logger.Socket.Warn("sending data failed, connection lost");
            #endif
                    IsConnectionError = true;
                    return false;
                } catch (ObjectDisposedException) {
            #if LOG4NET
                    Logger.Socket.Warn("sending data failed (stream error), connection lost");
            #endif
                    IsConnectionError = true;
                    return false;
                }

            #if LOG4NET
                Logger.Socket.Debug("sent: \""+data+"\"");
            #endif
                if (OnWriteLine != null) {
                    OnWriteLine(this, new WriteLineEventArgs(data));
                }
                return true;
            }

            return false;
        }

Usage Example

Example #1
0
            private bool _CheckHighBuffer()
            {
                if (_HighCount > 0)
                {
                    string data = (string)((Queue)_Connection._SendBuffer[Priority.High]).Dequeue();
                    if (_Connection._WriteLine(data) == false)
                    {
#if LOG4NET
                        Logger.Queue.Warn("Sending data was not sucessful, data is requeued!");
#endif
                        ((Queue)_Connection._SendBuffer[Priority.High]).Enqueue(data);
                    }

                    if (_HighCount > 1)
                    {
                        // there is more data to send
                        return(false);
                    }
                }

                return(true);
            }