|
# File jabber4r/session.rb, line 153
def Session.register(jid, password, email="", name="", port=5222)
jid = Jabber::JID.new(jid) if jid.kind_of? String
session = Session.new(jid.host, port)
msg_id = session.id
registered = false
current = Thread.current
session.connection.send(Jabber::Protocol::Iq.gen_registration(session, msg_id, jid.node, password, email, name)) do |element|
if element.element_tag=="iq" and element.attr_id==msg_id
element.consume_element
if element.attr_type=="result"
registered = true
elsif element.attr_type=="error"
registered = false
end
current.wakeup
end
end
Thread.stop
session.release
return registered
end
|