Sha256: f65074fc2ea042a2cb702d348f3ee0658082b66a64a305e447775a8452c8edbd
Contents?: true
Size: 1.15 KB
Versions: 5
Compression:
Stored size: 1.15 KB
Contents
EventEmitter.apply Sinatra::RocketIO module Sinatra module RocketIO def self.push(type, data, opt={}) if options[:websocket] if !opt[:to] or Sinatra::WebSocketIO.sessions.include? opt[:to] Sinatra::WebSocketIO.push type, data, opt end end if options[:comet] if !opt[:to] or Sinatra::CometIO.sessions.include? opt[:to] Sinatra::CometIO.push type, data, opt end end end def self.sessions { :websocket => Sinatra::WebSocketIO.sessions, :comet => Sinatra::CometIO.sessions } end end end Sinatra::RocketIO.once :start do if options[:comet] Sinatra::CometIO.on :* do |event_name, *args| if args.size > 1 Sinatra::RocketIO.emit event_name, args[0], args[1], :comet else Sinatra::RocketIO.emit event_name, args[0], :comet end end end if options[:websocket] Sinatra::WebSocketIO.on :* do |event_name, *args| if args.size > 1 Sinatra::RocketIO.emit event_name, args[0], args[1], :websocket else Sinatra::RocketIO.emit event_name, args[0], :websocket end end end end
Version data entries
5 entries across 5 versions & 1 rubygems