Class: IRC::Client::Connection
- Inherits:
-
Object
- Object
- IRC::Client::Connection
- Defined in:
- lib/irc/client/context.rb,
lib/irc/client/connection.rb
Defined Under Namespace
Classes: Context
Constant Summary collapse
- MAX_CONNECTION_TIMEOUT_IN_SEC =
5
Instance Method Summary collapse
-
#<<(command) ⇒ Object
Sends the command to the server using the command queue.
-
#add_connection_listener(connection_listener) ⇒ Object
Adds a new connection listener.
-
#connect(server) ⇒ Object
Connects to the server.
-
#connected? ⇒ Boolean
Returns true if a connection to an IRC server has been established.
-
#connection_listeners ⇒ Object
Returns all registered connection listeners.
-
#disconnect(message = nil) ⇒ Object
Disconnects from the currently connected server.
-
#initialize(nick = nil, login = nil, realname = nil) ⇒ Connection
constructor
A new instance of Connection.
-
#join(channels) ⇒ Object
Joins the given channels.
-
#joined?(channel) ⇒ Boolean
Returns true, if the given channel is currently joined.
-
#joined_channels ⇒ Object
Returns an Array of all currently joined channels.
-
#network ⇒ Object
The network to which the context is connected, or nil if no connection has been established.
-
#nick ⇒ Object
Returns the nick name that is used when connected to an IRC server.
-
#nick=(new_nick) ⇒ Object
Returns the nick name that is used when connected to an IRC server.
-
#options ⇒ Object
Returns the supported options of the currently connected server.
-
#part(channels) ⇒ Object
Leaves the given channels.
-
#realname ⇒ Object
Returns the real name that is used when connected to an IRC server.
-
#register(nick = nil, login = nil, realname = nil) ⇒ Object
Register the connection by sending the password, nick and user commands.
-
#registered? ⇒ Boolean
Returns true if a connection to an IRC server has been established and the connection has been successfully registered.
-
#remove_connection_listener(connection_listener) ⇒ Object
Removes a previously added connection listener.
-
#send_command(command) ⇒ Object
Sends the command to the server bypassing the command queue.
-
#send_command_via_queue(command) ⇒ Object
Sends the command to the server using the command queue.
-
#server ⇒ Object
Returns the server, to which the connection object is connected to.
Constructor Details
#initialize(nick = nil, login = nil, realname = nil) ⇒ Connection
Returns a new instance of Connection.
37 38 39 |
# File 'lib/irc/client/connection.rb', line 37 def initialize(nick = nil, login = nil, realname = nil) @context = IRC::Client::Connection::Context.new(nick, login, realname) end |
Instance Method Details
#<<(command) ⇒ Object
Sends the command to the server using the command queue.
48 49 50 |
# File 'lib/irc/client/connection.rb', line 48 def <<(command) @context<<(command) end |
#add_connection_listener(connection_listener) ⇒ Object
Adds a new connection listener. The connection listener gets notified when a message was received from the IRC server.
43 44 45 |
# File 'lib/irc/client/connection.rb', line 43 def add_connection_listener(connection_listener) @context.add_connection_listener(connection_listener) end |
#connect(server) ⇒ Object
Connects to the server.
53 54 55 |
# File 'lib/irc/client/connection.rb', line 53 def connect(server) @context.connect(server) end |
#connected? ⇒ Boolean
Returns true if a connection to an IRC server has been established.
58 59 60 |
# File 'lib/irc/client/connection.rb', line 58 def connected? @context.connected? end |
#connection_listeners ⇒ Object
Returns all registered connection listeners.
63 64 65 |
# File 'lib/irc/client/connection.rb', line 63 def connection_listeners return @context.connection_listeners end |
#disconnect(message = nil) ⇒ Object
Disconnects from the currently connected server.
68 69 70 |
# File 'lib/irc/client/connection.rb', line 68 def disconnect( = nil) @context.disconnect() end |
#join(channels) ⇒ Object
Joins the given channels.
73 74 75 |
# File 'lib/irc/client/connection.rb', line 73 def join(channels) @context.join(channels) end |
#joined?(channel) ⇒ Boolean
Returns true, if the given channel is currently joined.
78 79 80 |
# File 'lib/irc/client/connection.rb', line 78 def joined?(channel) @context.joined?(channel) end |
#joined_channels ⇒ Object
Returns an Array of all currently joined channels.
83 84 85 |
# File 'lib/irc/client/connection.rb', line 83 def joined_channels @context.joined_channels end |
#network ⇒ Object
The network to which the context is connected, or nil if no connection has been established.
88 89 90 |
# File 'lib/irc/client/connection.rb', line 88 def network @context.network end |
#nick ⇒ Object
Returns the nick name that is used when connected to an IRC server.
93 94 95 |
# File 'lib/irc/client/connection.rb', line 93 def nick @context.nick end |
#nick=(new_nick) ⇒ Object
Returns the nick name that is used when connected to an IRC server.
98 99 100 |
# File 'lib/irc/client/connection.rb', line 98 def nick=(new_nick) @context.change_nick(new_nick) end |
#options ⇒ Object
Returns the supported options of the currently connected server.
103 104 105 |
# File 'lib/irc/client/connection.rb', line 103 def return @context. end |
#part(channels) ⇒ Object
Leaves the given channels.
108 109 110 |
# File 'lib/irc/client/connection.rb', line 108 def part(channels) @context.part(channels) end |
#realname ⇒ Object
Returns the real name that is used when connected to an IRC server.
113 114 115 |
# File 'lib/irc/client/connection.rb', line 113 def realname @context.realname end |
#register(nick = nil, login = nil, realname = nil) ⇒ Object
Register the connection by sending the password, nick and user commands.
118 119 120 |
# File 'lib/irc/client/connection.rb', line 118 def register(nick = nil, login = nil, realname = nil) @context.register(nick, login, realname) end |
#registered? ⇒ Boolean
Returns true if a connection to an IRC server has been established and the connection has been successfully registered.
124 125 126 |
# File 'lib/irc/client/connection.rb', line 124 def registered? @context.registered? end |
#remove_connection_listener(connection_listener) ⇒ Object
Removes a previously added connection listener. The connection listener will not get notified any longer when a message was received from the IRC server.
130 131 132 |
# File 'lib/irc/client/connection.rb', line 130 def remove_connection_listener(connection_listener) @context.remove_connection_listener(connection_listener) end |
#send_command(command) ⇒ Object
Sends the command to the server bypassing the command queue.
135 136 137 |
# File 'lib/irc/client/connection.rb', line 135 def send_command(command) @context.send_command(command) end |
#send_command_via_queue(command) ⇒ Object
Sends the command to the server using the command queue.
140 141 142 |
# File 'lib/irc/client/connection.rb', line 140 def send_command_via_queue(command) @context.send_command_via_queue(command) end |
#server ⇒ Object
Returns the server, to which the connection object is connected to.
145 146 147 |
# File 'lib/irc/client/connection.rb', line 145 def server return @context.server end |