Class: WAMP::Server
Instance Attribute Summary collapse
-
#callbacks ⇒ Object
Returns the value of attribute callbacks.
-
#engine ⇒ Object
Returns the value of attribute engine.
-
#options ⇒ Object
Returns the value of attribute options.
-
#topics ⇒ Object
Returns the value of attribute topics.
Instance Method Summary collapse
- #available_bindings ⇒ Object
-
#initialize(options = {}) ⇒ Server
constructor
A new instance of Server.
- #start ⇒ Object
Methods included from Bindable
Constructor Details
#initialize(options = {}) ⇒ Server
Returns a new instance of Server.
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/wamp/server.rb', line 10 def initialize( = {}) @options = @options[:engine] ||= {} @options[:engine][:type] ||= :memory @topics = {} @callbacks = {} @engine = WAMP::Engines.const_get(camelize(@options[:engine][:type])).new(@options[:engine]) @protocol = WAMP::Protocols::Version1.new end |
Instance Attribute Details
#callbacks ⇒ Object
Returns the value of attribute callbacks.
8 9 10 |
# File 'lib/wamp/server.rb', line 8 def callbacks @callbacks end |
#engine ⇒ Object
Returns the value of attribute engine.
8 9 10 |
# File 'lib/wamp/server.rb', line 8 def engine @engine end |
#options ⇒ Object
Returns the value of attribute options.
8 9 10 |
# File 'lib/wamp/server.rb', line 8 def @options end |
#topics ⇒ Object
Returns the value of attribute topics.
8 9 10 |
# File 'lib/wamp/server.rb', line 8 def topics @topics end |
Instance Method Details
#available_bindings ⇒ Object
21 22 23 |
# File 'lib/wamp/server.rb', line 21 def available_bindings [:subscribe, :unsubscribe, :publish, :call, :prefix, :connect, :disconnect] end |
#start ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/wamp/server.rb', line 25 def start lambda do |env| Faye::WebSocket.load_adapter('thin') if Faye::WebSocket.websocket?(env) ws = Faye::WebSocket.new(env, ['wamp'], ping: 25) ws.onopen = lambda { |event| handle_open(ws, event) } ws. = lambda { |event| (ws, event) } ws.onclose = lambda { |event| handle_close(ws, event) } ws.rack_response else # Normal HTTP request [200, {'Content-Type' => 'text/plain'}, ['Hello']] end end end |