Sha256: 314dc0ce32b9115392f48e0f73d8102224a4443df92198e90cc4be67205356d5

Contents?: true

Size: 654 Bytes

Versions: 3

Compression:

Stored size: 654 Bytes

Contents

# frozen_string_literal: true

require_relative "base"

module Wamp
  module Manager
    module Event
      # Unsubscribe Message Event
      class Unsubscribe < Base
        def add_event_listener(handler)
          session.on(listen_event_name) do |unsubscribed, error|
            session.off(listen_event_name)
            handler&.call(unsubscribed, error)
            remove_event_listening
          end
          session.transmit(payload)
        end

        def remove_event_listening
          session.off(clear_event_name)
        end

        def clear_event_name
          "event_#{subscription_id}"
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
xconn-0.1.2 lib/wamp/manager/event/unsubscribe.rb
xconn-0.1.1 lib/wamp/manager/event/unsubscribe.rb
xconn-0.1.0 lib/wamp/manager/event/unsubscribe.rb