-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathREADME
67 lines (53 loc) · 1.87 KB
/
README
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
This is a demo rails application to show how to have your rails app
post to an xmpp pubsub node.
What you will need:
ejabberd
A good tutorial on how to setup ejabberd,
http://metajack.im/2010/02/04/screencast-setting-up-ejabberd/
rails3
xmpp4r
strophejs
Can be found at http://code.stanziq.com/strophe
Download strophejs, run make
tape
Can be found at http://github.com/metajack/tape
Quickstart:
Install the above dependencies.
git clone http://github.com/thepug/railsrealtimedemo
cd railsrealtimedemo
rake db:migrate
rails s
open a new shell
cd railsrealtimedemo/public
tape -P /http-bind=http://localhost:5280/http-bind
open a new shell
cd lib
edit config.yml and change username and password to your xmpp user
go to http://localhost:8273 and login with the user
go to http://localhost:3000/posts and ad a new post
If you go back to http://localhost:8273 you will see the resulting post in xml
Details:
Install dependencies at the beginning of this readme.
The project at http://github.com/thepug/railsrealtimedemo is the
simple blog post demo that everyone uses. The difference is the post
model contains a hook that publishes the xml version of the model to a
pubsub node.
require 'xmpp_publish'
class Post < ActiveRecord::Base
after_save {
begin
publish(self.to_xml)
rescue Exception=> e
logger.info(e)
end
}
end
The xmpp_publish module is in the lib directory. It contains the
xmpp4r code to publish to a pubsub node. You can also use the script
lib/test_createnode.rb to create your pubsub node.
When you make a change or create a Post the new info will be published
to your node. An example javascript program is included to demo the
xml that is published.
The javascript program uses strophe and the strophe pubsub plugin to
subscribe to your node and display the xml it recieves. See
public/javascripts/basic.js and public/index.html for the demo code.