Sha256: eb5eedcdfec518e727b6c2f517c212858952ae3f54d1d563c05db5546ff8a52c
Contents?: true
Size: 950 Bytes
Versions: 3
Compression:
Stored size: 950 Bytes
Contents
require 'rubygems' require File.expand_path('../../lib/faye/websocket', __FILE__) require 'rack' require 'eventmachine' port = ARGV[0] || 7000 secure = ARGV[1] == 'ssl' static = Rack::File.new(File.dirname(__FILE__)) app = lambda do |env| if env['HTTP_UPGRADE'] socket = Faye::WebSocket.new(env) p [:open, socket.url, socket.version] socket.onmessage = lambda do |event| socket.send(event.data) end socket.onclose = lambda do |event| p [:close, event.code, event.reason] socket = nil end [-1, {}, []] else static.call(env) end end EM.run { thin = Rack::Handler.get('thin') thin.run(app, :Port => port) do |server| if secure server.ssl = true server.ssl_options = { :private_key_file => File.expand_path('../../spec/server.key', __FILE__), :cert_chain_file => File.expand_path('../../spec/server.crt', __FILE__) } end end }
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
faye-websocket-0.1.2 | examples/server.rb |
faye-websocket-0.1.1 | examples/server.rb |
faye-websocket-0.1.0 | examples/server.rb |