360: def subscribe(to, name="")
361: to = JID.to_jid(to)
362: roster_item = @roster[to]
363:
364: if roster_item
365: if roster_item.subscription=="to" or roster_item.subscription=="both"
366: return
367: end
368: @connection.send(Jabber::Protocol::Presence.gen_new_subscription(to))
369: return
370: end
371: myid = self.id
372: @connection.send(Jabber::Protocol::Iq.gen_add_rosteritem(self, myid, to, name)) do |element|
373: if element.attr_id==myid
374: element.consume_element
375: if element.attr_type=="result"
376: @connection.send(Jabber::Protocol::Presence.gen_new_subscription(to))
377: end
378: end
379: end
380: end