WriteLine() public method

public WriteLine ( string data ) : void
data string
return void
Example #1
0
 public static void IrcConnectionList()
 {
     IrcConnection irc = new IrcConnection();
     irc.OnReadLine += new ReadLineEventHandler(IrcConnectionListCallback);
     irc.Connect(SERVER, PORT);
     irc.WriteLine(Rfc2812.Nick(NICK), Priority.Critical);
     irc.WriteLine(Rfc2812.User(NICK, 0, REALNAME), Priority.Critical);
     irc.WriteLine(Rfc2812.List(CHANNEL));
     irc.Listen();
 }
Example #2
0
            private void _Worker()
            {
#if LOG4NET
                Logger.Socket.Debug("IdleWorkerThread started");
#endif
                try {
                    while (_Connection.IsConnected)
                    {
                        if (_Connection.IsRegistered)
                        {
                            DateTime now            = DateTime.Now;
                            int      last_ping_sent = (int)(now - _Connection._LastPingSent).TotalSeconds;
                            int      last_pong_rcvd = (int)(now - _Connection._LastPongReceived).TotalSeconds;
                            // determins if the resoponse time is ok
                            if (last_ping_sent < _Connection._PingTimeout)
                            {
                                // determines if it need to send another ping yet
                                if (last_pong_rcvd > _Connection._PingInterval)
                                {
                                    _Connection.WriteLine(Rfc2812.Ping(_Connection.Address), Priority.Critical);
                                    _Connection._LastPingSent     = now;
                                    _Connection._LastPongReceived = now;
                                } // else connection is fine, just continue
                            }
                            else
                            {
#if LOG4NET
                                Logger.Socket.Warn("ping timeout, connection lost");
#endif
                                _Connection.IsConnectionError = true;
                                break;
                            }
                        }
                        Thread.Sleep(_Connection._IdleWorkerInterval);
                    }
                } catch (ThreadAbortException) {
                    Thread.ResetAbort();
#if LOG4NET
                    Logger.Socket.Debug("IdleWorkerThread aborted");
#endif
                }
            }
Example #3
0
            private void _Worker()
            {
#if LOG4NET
                Logger.Socket.Debug("IdleWorkerThread started");
#endif
                try {
                    while (_Connection.IsConnected)
                    {
                        Thread.Sleep(_Connection._IdleWorkerInterval);

                        // only send active pings if we are registered
                        if (!_Connection.IsRegistered)
                        {
                            continue;
                        }

                        DateTime now            = DateTime.Now;
                        int      last_ping_sent = (int)(now - _Connection._LastPingSent).TotalSeconds;
                        int      last_pong_rcvd = (int)(now - _Connection._LastPongReceived).TotalSeconds;
                        // determins if the resoponse time is ok
                        if (last_ping_sent < _Connection._PingTimeout)
                        {
                            if (_Connection._LastPingSent > _Connection._LastPongReceived)
                            {
                                // there is a pending ping request, we have to wait
                                continue;
                            }

                            // determines if it need to send another ping yet
                            if (last_pong_rcvd > _Connection._PingInterval)
                            {
                                _Connection.WriteLine(Rfc2812.Ping(_Connection.Address), Priority.Critical);
                                _Connection._LastPingSent = now;
                                //_Connection._LastPongReceived = now;
                            } // else connection is fine, just continue
                        }
                        else
                        {
                            if (_Connection.IsDisconnecting)
                            {
                                break;
                            }
#if LOG4NET
                            Logger.Socket.Warn("ping timeout, connection lost");
#endif
                            // only flag this as connection error if we are not
                            // cleanly disconnecting
                            _Connection.IsConnectionError = true;
                            break;
                        }
                    }
                } catch (ThreadAbortException) {
                    Thread.ResetAbort();
#if LOG4NET
                    Logger.Socket.Debug("IdleWorkerThread aborted");
#endif
                } catch (Exception ex) {
#if LOG4NET
                    Logger.Socket.Error(ex);
#endif
                }
            }