|
# File jabber4r/session.rb, line 360
def subscribe(to, name="")
to = JID.to_jid(to)
roster_item = @roster[to]
if roster_item #if you already have a roster item just send the subscribe request
if roster_item.subscription=="to" or roster_item.subscription=="both"
return
end
@connection.send(Jabber::Protocol::Presence.gen_new_subscription(to))
return
end
myid = self.id
@connection.send(Jabber::Protocol::Iq.gen_add_rosteritem(self, myid, to, name)) do |element|
if element.attr_id==myid
element.consume_element
if element.attr_type=="result"
@connection.send(Jabber::Protocol::Presence.gen_new_subscription(to))
end
end
end
end
|