Class: Wamp::Connection::WebSocketConnection

Inherits:
Session
  • Object
show all
Defined in:
lib/wamp/connection/websocket_connection.rb

Overview

Conn

Instance Attribute Summary collapse

Attributes inherited from Session

#api, #executor, #joiner, #session, #store, #stream

Instance Method Summary collapse

Methods inherited from Session

#on_join, #on_message

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

#urlObject (readonly)

Returns the value of attribute url.



10
11
12
# File 'lib/wamp/connection/websocket_connection.rb', line 10

def url
  @url
end

#websocketObject (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_errorObject



37
# File 'lib/wamp/connection/websocket_connection.rb', line 37

def on_error; end

#on_openObject



25
26
27
# File 'lib/wamp/connection/websocket_connection.rb', line 25

def on_open
  transmit joiner.send_hello
end

#runObject



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