XMPP4R 介绍
XMPP4R是一个XMPP/Jabber的Ruby类库。它的目标是提供开发Jabber相关应用程序或者Ruby脚本的完整框架。
安装方法:gem install xmpp4r
示例代码:
# Send a message to a friend, asking for authorization if necessary: im = Jabber::Simple.new("[email protected]", "password") im.deliver("[email protected]", "hey there friend!") # Get received messages and print them out to the console: im.received_messages { |msg| puts msg.body if msg.type == :chat } # Send an authorization request to a user: im.add("[email protected]") # Get presence updates from your friends, and print them out to the console: # (admittedly, this one needs some work) im.presence_updates { |update| from = update[0].jid.strip.to_s status = update[2].status presence = update[2].show puts "#{from} went #{presence}: #{status}" end # Remove a user from your contact list: im.remove("[email protected]") # See the Jabber::Simple documentation for more @R_350_4045@ion.
XMPP4R 官网
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。