Sha256: d2d5be7e7a2b7c4a0c707e4e11070be1e56e4b3ae8c882cdfe076225f6fbbf1d

Contents?: true

Size: 1.59 KB

Versions: 23

Compression:

Stored size: 1.59 KB

Contents

# Toplevel Pubnub module.
module Pubnub
  # Holds where_now functionality
  class WhereNow < SingleEvent
    include Concurrent::Async
    include Pubnub::Validator::WhereNow

    def initialize(options, app)
      super
      @telemetry_name = :l_pres
      @uuid_looking_for = options[:uuid] || options['uuid']
      @uuid = app.uuid
      @event = :where_now
    end

    private

    def current_operation
      Pubnub::Constants::OPERATION_WHERE_NOW
    end

    def path
      '/' + [
        'v2',
        'presence',
        'sub-key',
        @subscribe_key,
        'uuid',
        Formatter.encode(@uuid_looking_for)
      ].join('/')
    end

    def valid_envelope(parsed_response, req_res_objects)
      Pubnub::Envelope.new(
        event: @event,
        event_options: @given_options,
        timetoken: nil,
        status: {
          code: req_res_objects[:response].code,
          client_request: req_res_objects[:request],
          server_response: req_res_objects[:response],
          data: nil,
          category: Pubnub::Constants::STATUS_ACK,
          error: false,
          auto_retried: false,

          current_timetoken: nil,
          last_timetoken: nil,
          subscribed_channels: nil,
          subscribed_channel_groups: nil,

          config: get_config

        },
        result: {
          code: req_res_objects[:response].code,
          operation: Pubnub::Constants::OPERATION_WHERE_NOW,
          client_request: req_res_objects[:request],
          server_response: req_res_objects[:response],

          data: parsed_response['payload']
        }
      )
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
pubnub-5.0.0 lib/pubnub/events/where_now.rb
pubnub-4.8.0 lib/pubnub/events/where_now.rb
pubnub-4.7.1 lib/pubnub/events/where_now.rb
pubnub-4.7.0 lib/pubnub/events/where_now.rb
pubnub-4.6.2 lib/pubnub/events/where_now.rb
pubnub-4.6.1 lib/pubnub/events/where_now.rb
pubnub-4.6.0 lib/pubnub/events/where_now.rb
pubnub-4.5.0 lib/pubnub/events/where_now.rb
pubnub-4.4.0 lib/pubnub/events/where_now.rb
pubnub-4.3.0 lib/pubnub/events/where_now.rb
pubnub-4.2.7 lib/pubnub/events/where_now.rb
pubnub-4.2.6 lib/pubnub/events/where_now.rb
pubnub-4.2.5 lib/pubnub/events/where_now.rb
pubnub-4.2.4 lib/pubnub/events/where_now.rb
pubnub-4.2.3 lib/pubnub/events/where_now.rb
pubnub-4.2.2 lib/pubnub/events/where_now.rb
pubnub-4.2.1 lib/pubnub/events/where_now.rb
pubnub-4.2.0 lib/pubnub/events/where_now.rb
pubnub-4.1.6 lib/pubnub/events/where_now.rb
pubnub-4.1.5 lib/pubnub/events/where_now.rb