XMPP/Jabber的Ruby类库 XMPP4R
<p>XMPP4R是一个XMPP/Jabber的Ruby类库。它的目标是提供开发Jabber相关应用程序或者Ruby脚本的完整框架。</p> <ul> <li>完整面向对象</li> <li>旨在XMPP协议兼容</li> <li>Threaded, events-based</li> <li>良好的单元测试和文档代码</li> <li>Uses well-known and well-tested software like REXML, instead of reinventing the wheel</li> <li>Very easy to extend</li> </ul> <p>安装方法:<code>gem install xmpp4r</code></p> <p>示例代码:</p> <pre class="brush:ruby; toolbar: true; auto-links: false;"> # Send a message to a friend, asking for authorization if necessary: im = Jabber::Simple.new("user@example.com", "password") im.deliver("friend@example.com", "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("friend@example.com") # 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("unfriendly@example.com") # See the Jabber::Simple documentation for more information.</pre>http://home.gna.org/xmpp4r/ <p></p>
本文由用户 fmms 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
转载本站原创文章,请注明出处,并保留原始链接、图片水印。
本站是一个以用户分享为主的开源技术平台,欢迎各类分享!