Module: Coffeemaker::Bot::Irc::Connection
- Includes:
- Commands, EM::Deferrable, EM::Protocols::LineText2
- Defined in:
- lib/coffeemaker/bot/irc/connection.rb
Defined Under Namespace
Classes: Error
Instance Attribute Summary collapse
-
#host ⇒ Object
Returns the value of attribute host.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#nick ⇒ Object
Returns the value of attribute nick.
-
#on_connect ⇒ Object
Returns the value of attribute on_connect.
-
#on_message ⇒ Object
Returns the value of attribute on_message.
-
#pass ⇒ Object
Returns the value of attribute pass.
-
#port ⇒ Object
Returns the value of attribute port.
-
#ssl ⇒ Object
Returns the value of attribute ssl.
-
#user ⇒ Object
Returns the value of attribute user.
Instance Method Summary collapse
- #connection_completed ⇒ Object
- #receive_line(data) ⇒ Object
- #ssl_handshake_completed ⇒ Object
- #unbind ⇒ Object
Methods included from Commands
Instance Attribute Details
#host ⇒ Object
Returns the value of attribute host.
16 17 18 |
# File 'lib/coffeemaker/bot/irc/connection.rb', line 16 def host @host end |
#logger ⇒ Object
Returns the value of attribute logger.
16 17 18 |
# File 'lib/coffeemaker/bot/irc/connection.rb', line 16 def logger @logger end |
#nick ⇒ Object
Returns the value of attribute nick.
16 17 18 |
# File 'lib/coffeemaker/bot/irc/connection.rb', line 16 def nick @nick end |
#on_connect ⇒ Object
Returns the value of attribute on_connect.
16 17 18 |
# File 'lib/coffeemaker/bot/irc/connection.rb', line 16 def on_connect @on_connect end |
#on_message ⇒ Object
Returns the value of attribute on_message.
16 17 18 |
# File 'lib/coffeemaker/bot/irc/connection.rb', line 16 def @on_message end |
#pass ⇒ Object
Returns the value of attribute pass.
16 17 18 |
# File 'lib/coffeemaker/bot/irc/connection.rb', line 16 def pass @pass end |
#port ⇒ Object
Returns the value of attribute port.
16 17 18 |
# File 'lib/coffeemaker/bot/irc/connection.rb', line 16 def port @port end |
#ssl ⇒ Object
Returns the value of attribute ssl.
16 17 18 |
# File 'lib/coffeemaker/bot/irc/connection.rb', line 16 def ssl @ssl end |
#user ⇒ Object
Returns the value of attribute user.
16 17 18 |
# File 'lib/coffeemaker/bot/irc/connection.rb', line 16 def user @user end |
Instance Method Details
#connection_completed ⇒ Object
18 19 20 21 |
# File 'lib/coffeemaker/bot/irc/connection.rb', line 18 def connection_completed return complete_connection unless @ssl start_tls end |
#receive_line(data) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/coffeemaker/bot/irc/connection.rb', line 28 def receive_line(data) msg = ::Coffeemaker::Bot::Irc::Message.new(data) @logger.debug "received #{data}" case msg.command when :'001' on_connect.call if on_connect succeed when :ping send_command :pong when :privmsg, :topic, :part, :join .call(msg) if end end |
#ssl_handshake_completed ⇒ Object
23 24 25 26 |
# File 'lib/coffeemaker/bot/irc/connection.rb', line 23 def ssl_handshake_completed @logger.info "ssl handshake completed" complete_connection end |
#unbind ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/coffeemaker/bot/irc/connection.rb', line 43 def unbind @logger.info "diconnected" @deferred_status = nil if @connected or @reconnecting EM.add_timer(1) do @logger.info "reconnecting" reconnect(@host, @port) end @connected = false @reconnecting = true else raise Error, "unable to connect to server #{@host}:#{@port}" end end |