Class: BotConnection
- Inherits:
-
Object
- Object
- BotConnection
- Defined in:
- lib/BotnetV2/Network.rb
Instance Method Summary collapse
- #close ⇒ Object
- #closed? ⇒ Boolean
-
#initialize(socket, network) ⇒ BotConnection
constructor
A new instance of BotConnection.
- #on_message_handler_loop(on_message_handler) ⇒ Object
- #read ⇒ Object
- #send(msg) ⇒ Object
Constructor Details
#initialize(socket, network) ⇒ BotConnection
Returns a new instance of BotConnection.
11 12 13 14 |
# File 'lib/BotnetV2/Network.rb', line 11 def initialize(socket, network) @socket = socket @network = network end |
Instance Method Details
#close ⇒ Object
34 35 36 |
# File 'lib/BotnetV2/Network.rb', line 34 def close @network.close @socket unless closed? end |
#closed? ⇒ Boolean
38 39 40 |
# File 'lib/BotnetV2/Network.rb', line 38 def closed? @socket.closed? end |
#on_message_handler_loop(on_message_handler) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/BotnetV2/Network.rb', line 16 def begin until closed? do .call read end rescue => e puts e.backtrace end end |
#read ⇒ Object
30 31 32 |
# File 'lib/BotnetV2/Network.rb', line 30 def read @network.read @socket unless closed? end |
#send(msg) ⇒ Object
26 27 28 |
# File 'lib/BotnetV2/Network.rb', line 26 def send msg @network.send msg, @socket unless closed? end |