class Wamp::Client::Transport::Base
Attributes
Public Class Methods
Method to add a tick loop to the event machine
# File lib/wamp/client/transport/base.rb, line 77 def self.add_tick_loop(&block) # Implement in subclass end
Process the callback when the timer expires @param [Integer] milliseconds - The number @param [block] callback - The callback that is fired when the timer expires
# File lib/wamp/client/transport/base.rb, line 59 def self.add_timer(milliseconds, &callback) # Implement in subclass end
Constructor for the transport @param options [Hash] The connection options. the different options are as follows @option options [String] :uri The url to connect to @option options [String] :proxy The proxy to use @option options [String] :protocol The protocol @option options [Hash] :headers Custom headers to include during the connection @option options [WampClient::Serializer::Base] :serializer The serializer to use
# File lib/wamp/client/transport/base.rb, line 21 def initialize(options) # Initialize the parameters self.connected = false self.uri = options[:uri] self.proxy = options[:proxy] self.headers = options[:headers] || {} self.protocol = options[:protocol] || 'wamp.2.json' self.serializer = options[:serializer] || Wamp::Client::Serializer::JSONSerializer.new # Add the wamp.2.json protocol header self.headers['Sec-WebSocket-Protocol'] = self.protocol end
Method to start the event machine for the socket
# File lib/wamp/client/transport/base.rb, line 67 def self.start_event_machine(&block) # Implement in subclass end
Method to stop the vent machine
# File lib/wamp/client/transport/base.rb, line 72 def self.stop_event_machine # Implement in subclass end
Public Instance Methods
# File lib/wamp/client/transport/base.rb, line 62 def add_timer(milliseconds, &callback) self.class.add_timer(milliseconds, &callback) end
Connects to the WAMP Server using the transport
# File lib/wamp/client/transport/base.rb, line 36 def connect # Implement in subclass end
Returns true if the transport it connected
# File lib/wamp/client/transport/base.rb, line 46 def connected? self.connected end
Disconnects from the WAMP Server
# File lib/wamp/client/transport/base.rb, line 41 def disconnect # Implement in subclass end
Sends a Message
@param [Array] msg - The message payload to send
# File lib/wamp/client/transport/base.rb, line 52 def send_message(msg) # Implement in subclass end