class Wamp::Client::Transport::Base

Attributes

connected[RW]
headers[RW]
protocol[RW]
proxy[RW]
serializer[RW]
uri[RW]

Public Class Methods

add_tick_loop(&block) click to toggle source

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
add_timer(milliseconds, &callback) click to toggle source

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
new(options) click to toggle source

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
start_event_machine(&block) click to toggle source

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
stop_event_machine() click to toggle source

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

add_timer(milliseconds, &callback) click to toggle source
# File lib/wamp/client/transport/base.rb, line 62
def add_timer(milliseconds, &callback)
  self.class.add_timer(milliseconds, &callback)
end
connect() click to toggle source

Connects to the WAMP Server using the transport

# File lib/wamp/client/transport/base.rb, line 36
def connect
  # Implement in subclass
end
connected?() click to toggle source

Returns true if the transport it connected

# File lib/wamp/client/transport/base.rb, line 46
def connected?
  self.connected
end
disconnect() click to toggle source

Disconnects from the WAMP Server

# File lib/wamp/client/transport/base.rb, line 41
def disconnect
  # Implement in subclass
end
send_message(msg) click to toggle source

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