Sha256: 5b03ae657b4e393dbf0860ba65c917e36981857ded9c432276758c0362c68e01

Contents?: true

Size: 1.54 KB

Versions: 37

Compression:

Stored size: 1.54 KB

Contents

# Toplevel Pubnub module.
module Pubnub
  # Holds leave functionality
  class Leave < SingleEvent
    include Concurrent::Async
    include Pubnub::Validator::Leave

    def initialize(options, app)
      @event = :leave
      @telemetry_name = :l_pub
      super
    end

    def fire
      @app.subscriber.remove_subscription(self)
      @app.subscriber.reset
      super
    end

    private

    def current_operation
      Pubnub::Constants::OPERATION_PRESENCE_LEAVE
    end

    def path
      '/' + [
        'v2',
        'presence',
        'sub-key',
        @subscribe_key,
        'channel',
        Formatter.channels_for_url(@channel),
        'leave'
      ].join('/')
    end

    def parameters(*_args)
      params = super
      params['channel-group'] = @group.join(',') unless @group.empty?
      params
    end

    def valid_envelope(parsed_response, req_res_objects)
      Pubnub::Envelope.new(
        event: @event,
        event_options: @given_options,
        timetoken: nil,
        status: {
          code: parsed_response['status'],
          operation: Pubnub::Constants::OPERATION_PRESENCE_LEAVE,
          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
        }
      )
    end
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

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