Class: IRC::Commands::PingCommand
- Defined in:
- lib/irc/commands/ping_command.rb
Overview
4.6.2 Ping message
Command: PING Parameters: <server1> [<server2>]
The PING message is used to test the presence of an active client at the other end of the connection. A PING message is sent at regular intervals if no other activity detected coming from a connection. If a connection fails to respond to a PING command within a set amount of time, that connection is closed.
Any client which receives a PING message must respond to <server1> (server which sent the PING message out) as quickly as possible with an appropriate PONG message to indicate it is still there and alive. Servers should not respond to PING commands but rely on PINGs from the other end of the connection to indicate the connection is alive. If the <server2> parameter is specified, the PING message gets forwarded there.
Numeric Replies:
-
ERR_NOORIGIN
-
ERR_NOSUCHSERVER
Examples:
PING tolsun.oulu.fi ; server sending a PING message to
another server to indicate it is still
alive.
PING WiZ ; PING message being sent to nick WiZ
Instance Attribute Summary collapse
-
#first_server ⇒ Object
readonly
Returns the value of attribute first_server.
-
#second_server ⇒ Object
readonly
Returns the value of attribute second_server.
Instance Method Summary collapse
- #command ⇒ Object
-
#initialize(first_server, second_server = nil) ⇒ PingCommand
constructor
A new instance of PingCommand.
Methods inherited from Command
Constructor Details
#initialize(first_server, second_server = nil) ⇒ PingCommand
Returns a new instance of PingCommand.
66 67 68 69 |
# File 'lib/irc/commands/ping_command.rb', line 66 def initialize(first_server, second_server = nil) raise InvalidCommand.new("Can't create ping command. No server.") unless first_server @first_server, @second_server = first_server, second_server end |
Instance Attribute Details
#first_server ⇒ Object (readonly)
Returns the value of attribute first_server.
63 64 65 |
# File 'lib/irc/commands/ping_command.rb', line 63 def first_server @first_server end |
#second_server ⇒ Object (readonly)
Returns the value of attribute second_server.
64 65 66 |
# File 'lib/irc/commands/ping_command.rb', line 64 def second_server @second_server end |
Instance Method Details
#command ⇒ Object
71 72 73 |
# File 'lib/irc/commands/ping_command.rb', line 71 def command return "PING #{first_server} #{second_server != nil ? second_server.to_s : ''}".strip end |