Class: Faye::Subscription

Inherits:
Object
  • Object
show all
Includes:
EventMachine::Deferrable
Defined in:
lib/faye/protocol/subscription.rb

Instance Method Summary collapse

Constructor Details

#initialize(client, channels, callback) ⇒ Subscription

Returns a new instance of Subscription.



5
6
7
8
9
10
# File 'lib/faye/protocol/subscription.rb', line 5

def initialize(client, channels, callback)
  @client    = client
  @channels  = channels
  @callback  = callback
  @cancelled = false
end

Instance Method Details

#cancelObject



12
13
14
15
16
# File 'lib/faye/protocol/subscription.rb', line 12

def cancel
  return if @cancelled
  @client.unsubscribe(@channels, &@callback)
  @cancelled = true
end

#unsubscribeObject



18
19
20
# File 'lib/faye/protocol/subscription.rb', line 18

def unsubscribe
  cancel
end