Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 15
- Log:
Attempt to update Typo to a Typo SVN HEAD release from around the
time the prototype installation was set up on the RISC OS Open Limited
web site. Timestamps place this at 04-Jul so a revision from 05-Jul or
earlier was pulled and copied over the 2.6.0 tarball stable code.
- Author:
- adh
- Date:
- Sat Jul 22 23:27:35 +0100 2006
- Size:
- 5994 Bytes
1 | Jabber4R is copyrighted free software by Rich Kilmer <rich@infoether.com> |
2 | Please see LICENSE.txt for licensing information. |
3 | Version: 0.8.0 |
4 | Date: August 15, 2005 |
5 | |
6 | ==== Overview |
7 | |
8 | The purpose of this library is to allow Ruby applications to talk to a Jabber IM system. |
9 | Jabber is an open-source instant messaging service, which can be learned about here. |
10 | |
11 | http://www.jabber.org |
12 | |
13 | An interesting facet of Jabber is its ability to represent multiple resources connecting |
14 | to a single account at the same time. One could connect to the account |
15 | account@jabber.org from home and from work and from a pda all at the same time. |
16 | Each connection is viewed as a resource. Messages can be sent to an account (and the |
17 | server will decide which resource gets it based on the resource’s priority) or to an |
18 | account+resource. The fully qualified account and resource name is: |
19 | |
20 | account@host/resource |
21 | |
22 | This library was created to allow a Ruby application to connect to an existing Jabber |
23 | account as an additional resource. This is not meant to be a library to create a complete |
24 | Ruby-based Jabber IM client. It currently does not support creation of accounts and |
25 | managing presence subscriptions (do that with one of the other 30 Jabber clients out |
26 | there). It was written for ease of use, not completeness. It does support: |
27 | |
28 | * Account registration |
29 | * Connection to an account (digest/plain text) |
30 | * Access to Roster (buddy list) |
31 | * Tracking of presence of resources in the Roster (including local account resources) |
32 | * Sending and receiving messages |
33 | * Requesting VCards |
34 | * Managing subscriptions |
35 | |
36 | What can you do with this? You could write a Ruby application that allows you to query |
37 | it by IM for status, control, etc. You could use this as a communications channel |
38 | backbone for a Ruby application (which is my intent). |
39 | |
40 | ==== Release Notes |
41 | |
42 | * Now have rake-based building and install. |
43 | |
44 | ==== Usage |
45 | |
46 | require 'jabber4r/jabber4r' |
47 | session = Jabber::Session.bind_digest("rich@jabber.com", "secret") |
48 | session.new_message("bob@jabber.com").set_body("ruby speak!").send |
49 | session.release |
50 | |
51 | You can send and receive messages. I make use of chaining on messages so you can do this |
52 | |
53 | session.add_message_listener do |message| |
54 | message.reply.set_body(“Echo: #{message.body}”).send |
55 | end |
56 | |
57 | If you want to send and wait for a reply message do: |
58 | |
59 | answer=session.new_chat_message("rich@jabber.com").set_body("Hello there").send(true) |
60 | |
61 | Then execute: |
62 | puts answer.body |
63 | answer.reply.set_body("Thanks for the reply").send |
64 | |
65 | The examples below demonstrate many features. |
66 | |
67 | Please look at the doc directory (RDoc format) for detailed info on Jabber4R. The |
68 | Jabber::Session class is kind of the main thing to focus on. |
69 | |
70 | I have a test directory with a single unit test file (for testing the JID class). |
71 | I will work on many more. There is also a fun echo.rb file there that you can run |
72 | to echo and messages back to the sender...and when they send 'shutdown' the session |
73 | releases. |
74 | |
75 | ruby echo.rb <jabberid> <password> |
76 | |
77 | You can observe roster changes, but cannot manage subscriptions (the framework is there |
78 | to do this, but it needs some work). You also cannot add an account (you must already |
79 | have one). That's in the works as well. |
80 | |
81 | Have fun! |
82 | |
83 | |
84 | == Installation |
85 | |
86 | To install, execute the following command: |
87 | |
88 | > gem install jabber4r |
89 | |
90 | That's it! |
91 | |
92 | ==== Examples |
93 | |
94 | NOTE: Remember to change your account@host/resource and password to YOURs. |
95 | |
96 | Connecting to an account, sending a message, and disconnecting: |
97 | |
98 | require 'jabber4r/jabber4r' |
99 | begin |
100 | session = Jabber::Session.bind('account@host/resource', 'password') |
101 | session.new_message('rich_kilmer@jabber.org').set_subject('hello').set_body('This is really cool').send |
102 | rescue Exception=>error |
103 | puts error |
104 | ensure |
105 | session.release if session |
106 | end |
107 | |
108 | ----------------- |
109 | |
110 | Connecting to an account, sending a message, waiting for a reply, and disconnecting: |
111 | |
112 | require 'jabber4r/jabber4r' |
113 | begin |
114 | session = Jabber::Session.bind('account@host/resource', 'password') |
115 | #NOTE: send the first message and wait for a reply (i.e. send(true) ) |
116 | message = session.new_chat_message('rich_kilmer@jabber.org').set_body('hey').send(true) |
117 | #NOTE: reply to the reply with an echo of the message, but don't wait |
118 | message.reply.set_body("You said #{message.body}").send |
119 | rescue Exception=>error |
120 | puts error |
121 | ensure |
122 | session.release if session |
123 | end |
124 | |
125 | ----------------- |
126 | |
127 | Connecting to an account, echoing back each received message, and disconnecting |
128 | when a shutdown message is received: |
129 | |
130 | |
131 | require "jabber4r/jabber4r" |
132 | begin |
133 | session = Jabber::Session.bind("account@host/resource", "password") |
134 | myThread = Thread.current |
135 | mlid = session.add_message_listener do |message| |
136 | message.reply.set_body("Echo: #{message.body}").send |
137 | myThread.wakeup if message.body=="shutdown" |
138 | end |
139 | Thread.stop |
140 | session.delete_message_listener(mlid) |
141 | rescue Exception=>error |
142 | puts error |
143 | ensure |
144 | session.release if session |
145 | end |
146 | |
147 | ----------------- |
148 | |
149 | Connecting to an account, outputting roster changes, and disconnecting when a |
150 | shutdown message is received: |
151 | |
152 | require "jabber4r/jabber4r" |
153 | begin |
154 | session = Jabber::Session.bind("account@host/resource", "password") |
155 | myThread = Thread.current |
156 | #NOTE: Just like before, a 'shutdown' message stops the session |
157 | mlid = session.add_message_listener do |message| |
158 | myThread.wakeup if message.body=="shutdown" |
159 | end |
160 | listenerid = session.add_roster_listener do |event, object| |
161 | case event |
162 | when Jabber::Roster::ITEM_ADDED |
163 | puts "Added item: #{object.to_s}" |
164 | when Jabber::Roster::ITEM_DELETED |
165 | puts "Deleted item: #{object.to_s}" |
166 | when Jabber::Roster::RESOURCE_ADDED |
167 | puts "Added resource: #{object.to_s}" |
168 | when Jabber::Roster::RESOURCE_DELETED |
169 | puts "Deleted resource: #{object.to_s}" |
170 | when Jabber::Roster::RESOURCE_UPDATED |
171 | puts "Updated resource: #{object.to_s}" |
172 | end |
173 | end |
174 | Thread.stop |
175 | rescue Exception=>error |
176 | puts error |
177 | ensure |
178 | session.release if session |
179 | end |
180 |