Class: Wisebed::WebsocketClient

Inherits:
Client
  • Object
show all
Defined in:
lib/wisebedclientruby/websocketclient.rb

Instance Method Summary collapse

Methods inherited from Client

#delete_from_wisebed, #experimentconfiguration, #post_to_wisebed, #request_from_wisebed, #testbeds

Constructor Details

#initialize(secret_exp_id) ⇒ WebsocketClient

Returns a new instance of WebsocketClient.



6
7
8
# File 'lib/wisebedclientruby/websocketclient.rb', line 6

def initialize(secret_exp_id)
  @secret_exp_id = secret_exp_id
end

Instance Method Details

#attach(&message_handler) ⇒ Object



10
11
12
# File 'lib/wisebedclientruby/websocketclient.rb', line 10

def attach(&message_handler)      
  @ws = WebSocket.new(Wisebed::WSBASEURL+"/ws/experiments/"+@secret_exp_id) { |msg| message_handler.call(msg) }
end

#detachObject



14
15
16
17
# File 'lib/wisebedclientruby/websocketclient.rb', line 14

def detach
  puts "WebSocket detaching..."
  @ws.close
end