Sha256: 64717395dac6dfeff0b561f28502756703a1134cc5d771cd936407e66cab31c6

Contents?: true

Size: 705 Bytes

Versions: 3

Compression:

Stored size: 705 Bytes

Contents

require 'rubypitaya/core/nats_connector'

module RubyPitaya

  class Postman

    MESSAGE_ROUTE_BIND_SESSION = 'sys.bindsession'

    def initialize(nats_connector)
      @nats_connector = nats_connector
    end

    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

    def push_to_user(uid, message_route, payload)
      @nats_connector.push_to_user(uid, message_route, payload)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rubypitaya-3.19.6 ./lib/rubypitaya/core/postman.rb
rubypitaya-3.19.5 ./lib/rubypitaya/core/postman.rb
rubypitaya-3.19.4 ./lib/rubypitaya/core/postman.rb