Class: Wamp::Connection::WebSocketConnection
- Defined in:
- lib/wamp/connection/websocket_connection.rb
Overview
Conn
Instance Attribute Summary collapse
-
#url ⇒ Object
readonly
Returns the value of attribute url.
-
#websocket ⇒ Object
readonly
Returns the value of attribute websocket.
Attributes inherited from Session
#api, #executor, #joiner, #session, #store, #stream
Instance Method Summary collapse
-
#initialize(url = "ws://localhost:8080/ws", joiner = Wampproto::Joiner.new("realm1")) ⇒ WebSocketConnection
constructor
A new instance of WebSocketConnection.
- #on_close(reason, code) ⇒ Object
- #on_error ⇒ Object
- #on_open ⇒ Object
- #run ⇒ Object
- #transmit(data) ⇒ Object
Methods inherited from Session
Constructor Details
#initialize(url = "ws://localhost:8080/ws", joiner = Wampproto::Joiner.new("realm1")) ⇒ WebSocketConnection
Returns a new instance of WebSocketConnection.
12 13 14 15 16 |
# File 'lib/wamp/connection/websocket_connection.rb', line 12 def initialize(url = "ws://localhost:8080/ws", joiner = Wampproto::Joiner.new("realm1")) super(joiner) @url = url @websocket = Wamp::Connection::WebsocketClient.new(self, protocols) end |
Instance Attribute Details
#url ⇒ Object (readonly)
Returns the value of attribute url.
10 11 12 |
# File 'lib/wamp/connection/websocket_connection.rb', line 10 def url @url end |
#websocket ⇒ Object (readonly)
Returns the value of attribute websocket.
10 11 12 |
# File 'lib/wamp/connection/websocket_connection.rb', line 10 def websocket @websocket end |
Instance Method Details
#on_close(reason, code) ⇒ Object
33 34 35 |
# File 'lib/wamp/connection/websocket_connection.rb', line 33 def on_close(reason, code) p [:on_close, reason, code] end |
#on_error ⇒ Object
37 |
# File 'lib/wamp/connection/websocket_connection.rb', line 37 def on_error; end |
#on_open ⇒ Object
25 26 27 |
# File 'lib/wamp/connection/websocket_connection.rb', line 25 def on_open transmit joiner.send_hello end |
#run ⇒ Object
18 19 20 21 22 23 |
# File 'lib/wamp/connection/websocket_connection.rb', line 18 def run websocket.run ensure p %i[run close] websocket.close end |
#transmit(data) ⇒ Object
29 30 31 |
# File 'lib/wamp/connection/websocket_connection.rb', line 29 def transmit(data) websocket.transmit data end |