Class: Guh::EM::Connection
- Inherits:
-
EventMachine::Connection
- Object
- EventMachine::Connection
- Guh::EM::Connection
- Defined in:
- lib/guh/em/connection.rb
Instance Method Summary collapse
Instance Method Details
#onmessage(&block) ⇒ Object
11 12 13 |
# File 'lib/guh/em/connection.rb', line 11 def (&block) @onmessage = block end |
#post_init ⇒ Object
15 16 17 18 19 20 |
# File 'lib/guh/em/connection.rb', line 15 def post_init request_string = Guh::Base.hash_to_json({id: Guh::Base.generate_request_id, method: "JSONRPC.SetNotificationStatus", params: { enabled: true } }) send_data(request_string) @message = "" end |
#receive_data(data) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/guh/em/connection.rb', line 22 def receive_data(data) data.each_line do |line| @message << line if line.match(/^\}\n/) (@message) @message = "" end end end |
#unbind ⇒ Object
35 36 37 |
# File 'lib/guh/em/connection.rb', line 35 def unbind # TODO implement a callback to enable the notification of all clients about lost connection end |