Sha256: d981d90285b62377e77f325d08fefd22f6d565336748008151c053e675b96985

Contents?: true

Size: 1.42 KB

Versions: 37

Compression:

Stored size: 1.42 KB

Contents

# Toplevel Pubnub module.
module Pubnub
  # Holds time functionality
  class Time < SingleEvent
    include Concurrent::Async
    include Pubnub::Validator::Time

    def initialize(options, app)
      @event = :time
      @telemetry_name = :l_time
      super
    end

    private

    def current_operation
      Pubnub::Constants::OPERATION_TIME
    end

    def path
      '/time/0'
    end

    def timetoken(parsed_response)
      parsed_response.first
    rescue StandardError
      nil
    end

    def valid_envelope(parsed_response, req_res_objects)
      Pubnub::Envelope.new(
        event: @event,
        event_options: @given_options,
        timetoken: timetoken(parsed_response),
        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_TIME,
          client_request: req_res_objects[:request],
          server_response: req_res_objects[:response]

        }
      )
    end
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
pubnub-5.5.0 lib/pubnub/events/time.rb
pubnub-5.4.0 lib/pubnub/events/time.rb
pubnub-5.3.5 lib/pubnub/events/time.rb
pubnub-5.3.4 lib/pubnub/events/time.rb
pubnub-5.3.3 lib/pubnub/events/time.rb
pubnub-5.3.2 lib/pubnub/events/time.rb
pubnub-5.3.1 lib/pubnub/events/time.rb
pubnub-5.3.0 lib/pubnub/events/time.rb
pubnub-5.2.2 lib/pubnub/events/time.rb
pubnub-5.2.1 lib/pubnub/events/time.rb
pubnub-5.2.0 lib/pubnub/events/time.rb
pubnub-5.1.2 lib/pubnub/events/time.rb
pubnub-5.1.1 lib/pubnub/events/time.rb
pubnub-5.1.0 lib/pubnub/events/time.rb
pubnub-5.0.0 lib/pubnub/events/time.rb
pubnub-4.8.0 lib/pubnub/events/time.rb
pubnub-4.7.1 lib/pubnub/events/time.rb
pubnub-4.7.0 lib/pubnub/events/time.rb
pubnub-4.6.2 lib/pubnub/events/time.rb
pubnub-4.6.1 lib/pubnub/events/time.rb