Class: Jabber::Subscription

Inherits:
Object
  • Object
show all
Defined in:
lib/jabber4r/session.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(session, type, from, id) ⇒ Subscription

Returns a new instance of Subscription.



44
45
46
47
48
49
# File 'lib/jabber4r/session.rb', line 44

def initialize(session, type, from, id)
  @session = session
  @type = type
  @from = from
  @id = id
end

Instance Attribute Details

#fromObject

Returns the value of attribute from.



43
44
45
# File 'lib/jabber4r/session.rb', line 43

def from
  @from
end

#idObject

Returns the value of attribute id.



43
44
45
# File 'lib/jabber4r/session.rb', line 43

def id
  @id
end

#sessionObject

Returns the value of attribute session.



43
44
45
# File 'lib/jabber4r/session.rb', line 43

def session
  @session
end

#typeObject

Returns the value of attribute type.



43
44
45
# File 'lib/jabber4r/session.rb', line 43

def type
  @type
end

Instance Method Details

#acceptObject



50
51
52
53
54
55
56
57
58
59
# File 'lib/jabber4r/session.rb', line 50

def accept
  case type
  when :subscribe
    @session.connection.send(Jabber::Protocol::Presence.gen_accept_subscription(@id, @from))
  when :unsubscribe
    @session.connection.send(Jabber::Protocol::Presence.gen_accept_unsubscription(@id, @from))
  else
    raise "Cannot accept a subscription of type #{type.to_s}"
  end
end