Class: Wamp::Router::Client
- Inherits:
-
Object
- Object
- Wamp::Router::Client
- Defined in:
- lib/wamp/router/client.rb
Overview
Server Session
Direct Known Subclasses
Instance Attribute Summary collapse
-
#acceptor ⇒ Object
readonly
Returns the value of attribute acceptor.
-
#connection ⇒ Object
Returns the value of attribute connection.
-
#router ⇒ Object
Returns the value of attribute router.
-
#serializer ⇒ Object
readonly
Returns the value of attribute serializer.
Instance Method Summary collapse
-
#initialize(serializer = Wampproto::Serializer::JSON, authenticator = Authenticator) ⇒ Client
constructor
A new instance of Client.
- #on_message(data) ⇒ Object
- #realm ⇒ Object
- #send_message(message) ⇒ Object
- #session_id ⇒ Object
- #transmit(data) ⇒ Object
Constructor Details
#initialize(serializer = Wampproto::Serializer::JSON, authenticator = Authenticator) ⇒ Client
Returns a new instance of Client.
19 20 21 22 |
# File 'lib/wamp/router/client.rb', line 19 def initialize(serializer = Wampproto::Serializer::JSON, authenticator = Authenticator) @serializer = serializer @acceptor = Wampproto::Acceptor.new(serializer, authenticator) end |
Instance Attribute Details
#acceptor ⇒ Object (readonly)
Returns the value of attribute acceptor.
17 18 19 |
# File 'lib/wamp/router/client.rb', line 17 def acceptor @acceptor end |
#connection ⇒ Object
Returns the value of attribute connection.
16 17 18 |
# File 'lib/wamp/router/client.rb', line 16 def connection @connection end |
#router ⇒ Object
Returns the value of attribute router.
16 17 18 |
# File 'lib/wamp/router/client.rb', line 16 def router @router end |
#serializer ⇒ Object (readonly)
Returns the value of attribute serializer.
17 18 19 |
# File 'lib/wamp/router/client.rb', line 17 def serializer @serializer end |
Instance Method Details
#on_message(data) ⇒ Object
45 46 47 48 49 50 51 52 |
# File 'lib/wamp/router/client.rb', line 45 def (data) unless acceptor.accepted? msg, is_welcome = acceptor.receive(data) transmit msg router.attach_client(self) if is_welcome end router.(self, serializer.deserialize(data)) end |
#realm ⇒ Object
24 25 26 |
# File 'lib/wamp/router/client.rb', line 24 def realm acceptor.session_details&.realm end |
#send_message(message) ⇒ Object
28 29 30 |
# File 'lib/wamp/router/client.rb', line 28 def () transmit() end |
#session_id ⇒ Object
32 33 34 |
# File 'lib/wamp/router/client.rb', line 32 def session_id acceptor.session_details&.session_id end |
#transmit(data) ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'lib/wamp/router/client.rb', line 36 def transmit(data) case data when Wampproto::Message::Base connection. serializer.serialize(data) else connection. data end end |