Class: RubyPitaya::Postman
- Inherits:
-
Object
- Object
- RubyPitaya::Postman
- Defined in:
- lib/rubypitaya/core/postman.rb
Constant Summary collapse
- MESSAGE_ROUTE_BIND_SESSION =
'sys.bindsession'
Instance Method Summary collapse
- #bind_session(session) ⇒ Object
-
#initialize(nats_connector) ⇒ Postman
constructor
A new instance of Postman.
- #push_to_user(uid, message_route, payload) ⇒ Object
Constructor Details
#initialize(nats_connector) ⇒ Postman
Returns a new instance of Postman.
9 10 11 |
# File 'lib/rubypitaya/core/postman.rb', line 9 def initialize(nats_connector) @nats_connector = nats_connector end |
Instance Method Details
#bind_session(session) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/rubypitaya/core/postman.rb', line 13 def bind_session(session) route = MESSAGE_ROUTE_BIND_SESSION nats_session = NatsSession.new( id: session.id, uid: session.uid.to_s, data: session.data.to_json, ) payload = NatsSession.encode(nats_session) response = @nats_connector.push_to_frontend(session, route, payload) response end |
#push_to_user(uid, message_route, payload) ⇒ Object
29 30 31 |
# File 'lib/rubypitaya/core/postman.rb', line 29 def push_to_user(uid, , payload) @nats_connector.push_to_user(uid, , payload) end |