public
Fork of blaine/xmpp4r-simple
Description: Fork of Jabber::Simple to add PubSub capabilities
Homepage: http://www.nardol.org/
Clone URL: git://github.com/spectra/xmpp4r-simple.git
xmpp4r-simple / README
100644 83 lines (60 sloc) 2.855 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
= Name
 
Jabber::Simple - An extremely easy-to-use Jabber client library.
 
= Synopsis
 
  # 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 do |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")
 
  # Create a PubSub node
  im.create_node("/anode")
 
  # Publishing something to the node
  im.publish_simple_item("/anode", "body", "something")
 
  # Subscribing to a node
  im.pubsubscribe_to("/anothernode")
 
  # Getting the PubSub Subscriptions (returns an array of Jabber::PubSub::Subscription objects)
  im.pubsubscriptions
 
  # Get events from PubSub service (Jabber::PubSub::Event)
  im.received_events { |event|
    items = event.children[0]
    node = items.node
    item = items.children[0]
    id = item.id
    text = item.children[0].text
    puts "You got an update on #{node} with text = #{text} (#{id})"
  }
 
  # See the Jabber::Simple documentation for more information.
 
= Description
 
Jabber::Simple is intended to make Jabber client programming dead simple. XMPP,
the Jabber protocol, is extremely powerful but also carries a steep learning
curve. This library exposes only the most common tasks, and does so in a way
that is familiar to users of traditional instant messenger clients.
 
= Known Issues
 
* None. If you'd like additional functionality, please contact the developer!
 
= Copyright
 
Jabber::Simple - An extremely easy-to-use Jabber client library.
Copyright 2006-2008 Blaine Cook <romeda@gmail.com>.
Various other contributions by several authors. Check AUTHORS file.
 
Jabber::Simple is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
 
Jabber::Simple is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
 
You should have received a copy of the GNU General Public License
along with Jabber::Simple; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA