Sha256: b8b03e952491aa67f67280b6ce20ce6a79e20568c013b6b9611818abdc4b3927
Contents?: true
Size: 1.13 KB
Versions: 1
Compression:
Stored size: 1.13 KB
Contents
module EventMachine module RocketIO class Client class Error < StandardError end include EventEmitter attr_reader :settings, :type, :io def initialize(url, opt={:type => :websocket}) @settings = JSON.parse HTTParty.get("#{url}/rocketio/settings").body type = opt[:type].to_sym if type == :websocket and @settings.include? 'websocket' @type = :websocket @io = EM::WebSocketIO::Client.new @settings['websocket'] elsif type == :comet or @settings.include? 'comet' @type = :comet @io = EM::CometIO::Client.new @settings['comet'] else raise Error, "cannot find #{type} IO #{url}" end this = self if @io @io.on :* do |event_name, *args| this.emit event_name, *args end end self end def connect @io.connect self end def close @io.close end def push(type, data={}) @io.push type, data end def method_missing(name, *args) @io.__send__ name, *args end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
em-rocketio-client-0.0.1 | lib/em-rocketio-client/client.rb |