XMPP transport to another protocol

强颜欢笑 提交于 2019-12-20 06:43:02

问题


I would like to add support of ICQ in my application using jabber-transport. I use xmpp4r ruby's library.

All that I found doesn't show how to login to external (icq) server and how to send messages.

Can you show example of code or text explanation how to do so? (may be not using xmpp4r and ruby, I only need a hint.)


回答1:


I found solution thanks to canhaschat plugin source code

require 'xmpp4r'

#connect to jabber
jid=Jabber::JID.new "your_jid"
client=Jabber::Client.new jid
client.connect
client.auth "your_jabber_password"

#connect to transport
reg=Jabber::Iq.new_register "your_login (e.g 123456789)", "your_password (e.g. qwerty)"
reg.to="transport server url (e.g. icq.udaff.com)"
client.send reg

#send message
client.send Jabber::Message.new "recipient_login@transport", "Hi there!"

#end of work... 
client.close


来源:https://stackoverflow.com/questions/4292482/xmpp-transport-to-another-protocol

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!