Class: Wamp::Client::Transport::EventMachineBase

Inherits:
Base
  • Object
show all
Defined in:
lib/wamp/client/transport/event_machine_base.rb

Direct Known Subclasses

FayeWebSocket, WebSocketEventMachine

Instance Attribute Summary

Attributes inherited from Base

#connected, #headers, #protocol, #proxy, #serializer, #uri

Class Method Summary collapse

Methods inherited from Base

#add_timer, #connect, #connected?, #disconnect, #initialize, #on, #on_close, #on_error, #on_message, #on_open, #send_message

Constructor Details

This class inherits a constructor from Wamp::Client::Transport::Base

Class Method Details

.add_tick_loop(&block) ⇒ Object



53
54
55
# File 'lib/wamp/client/transport/event_machine_base.rb', line 53

def self.add_tick_loop(&block)
  EM.tick_loop(&block)
end

.add_timer(milliseconds, &callback) ⇒ Object



46
47
48
49
50
51
# File 'lib/wamp/client/transport/event_machine_base.rb', line 46

def self.add_timer(milliseconds, &callback)
  delay = (milliseconds.to_f/1000.0).ceil
  EM.add_timer(delay) {
    callback.call
  }
end

.start_event_machine(&block) ⇒ Object



36
37
38
39
40
# File 'lib/wamp/client/transport/event_machine_base.rb', line 36

def self.start_event_machine(&block)
  EM.run do
    block.call
  end
end

.stop_event_machineObject



42
43
44
# File 'lib/wamp/client/transport/event_machine_base.rb', line 42

def self.stop_event_machine
  EM.stop
end