GitHub Sale: sign up for any paid plan this week and pay nothing until January 1, 2009!  [ hide ]

public
Description: A xmpp4r wrapper turned Rails plugin...with a few advanced features like user registration and multi-user chat sends.
Homepage: http://github.com/kitplummer/xmpp4rails/wikis/home
Clone URL: git://github.com/kitplummer/xmpp4rails.git
Added in MUC and simple send stuff.
Kit Plummer (author)
Tue Apr 22 16:11:46 -0700 2008
commit  8e97797e56debb2c5687448a34db52eaad14a695
tree    62a9d07e93323f94e8cfc91f574ee3162aa3b363
parent  860b0c0bcbd27a81aab535f22178d727d889d48b
...
19
20
21
 
22
23
24
...
35
36
37
38
 
39
40
41
...
51
52
53
54
 
55
56
57
58
59
60
61
62
63
64
...
70
71
72
73
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74
75
...
19
20
21
22
23
24
25
...
36
37
38
 
39
40
41
42
...
52
53
54
 
55
56
57
58
59
60
61
 
62
63
64
...
70
71
72
 
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
0
@@ -19,6 +19,7 @@
0
 #
0
 
0
 require 'xmpp4r'
0
+require 'xmpp4r/muc'
0
 
0
 module Xmpp4Rails
0
   def register_account jid, pw
0
@@ -35,7 +36,7 @@ module Xmpp4Rails
0
       # Shutdown
0
       cl.close
0
     rescue Errno::ECONNREFUSED
0
- raise StandardError, "Connection to XMPP Failed."
0
+ raise StandardError, "Connection to XMPP Server Failed."
0
     rescue Jabber::ErrorException
0
       raise StandardError, "Account conflict."
0
     end
0
@@ -51,14 +52,13 @@ module Xmpp4Rails
0
 
0
       cl.close
0
     rescue Errno::ECONNREFUSED
0
- raise StandardError, "Connection to XMPP Failed."
0
+ raise StandardError, "Connection to XMPP Server Failed."
0
     end
0
 
0
   end
0
   
0
   def change_password jid, current_pw, new_pw
0
     begin
0
- #cl = Jabber::Client.new(Jabber::JID.new(jid + "/rvooz"))
0
       cl = Jabber::Client::new(Jabber::JID.new(jid))
0
       logger.info "Connecting to change password for: " + jid.to_s
0
       cl.connect
0
@@ -70,5 +70,34 @@ module Xmpp4Rails
0
       raise StandardError, "Failed to change XMPP password."
0
     end
0
   end
0
-
0
+
0
+ def simple_send jid, pw, to_jid, message
0
+ begin
0
+ cl = Jabber::Client::new(Jabber::JID.new(jid))
0
+ cl.connect
0
+ cl.auth(pw)
0
+ m = Jabber::Message::new(to_jid, message).set_type(:normal).set_id('1')
0
+ cl.send(m)
0
+ cl.close
0
+ rescue
0
+ raise StandardError, "Failed to send XMPP message."
0
+ end
0
+ end
0
+
0
+ def connect jid, pw
0
+
0
+ @cl = Jabber::Client::new(Jabber::JID.new(jid))
0
+ @cl.connect
0
+ @cl.auth(pw)
0
+
0
+ end
0
+
0
+ def muc_join
0
+ @muc = Jabber::MUC::SimpleMUCClient.new(@cl)
0
+ end
0
+
0
+ def muc_simple_send message
0
+ @muc.say message
0
+ end
0
+
0
 end
0
\ No newline at end of file

Comments

    No one has commented yet.