strophe_ruby 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +48 -47
- data/Rakefile +1 -1
- data/ext/strophe_ruby/libstrophe.a +0 -0
- metadata +1 -1
data/README.rdoc
CHANGED
@@ -26,9 +26,12 @@ allows the ruby developer to write a XMPP bot in a few lines of code.
|
|
26
26
|
|
27
27
|
License: GNU General Public License (GPL)
|
28
28
|
|
29
|
-
==
|
29
|
+
== CURRENT PROBLEMS:
|
30
30
|
|
31
|
-
- Currently no Support for TLS
|
31
|
+
- Currently no Support for TLS encryption (Coming soon as it's rather important)
|
32
|
+
- Cannot terminate the loop with CTRL-C
|
33
|
+
- Socket disconnects after being inactive for too long
|
34
|
+
- Cannot output log data in a file
|
32
35
|
|
33
36
|
== SYNOPSIS:
|
34
37
|
|
@@ -42,52 +45,55 @@ end
|
|
42
45
|
|
43
46
|
def register_callbacks
|
44
47
|
@conn.add_handler("presence") do |pres|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
end
|
48
|
+
if pres.type == "subscribe"
|
49
|
+
|
50
|
+
#We accept everyone
|
51
|
+
stanza = StropheRuby::Stanza.new
|
52
|
+
stanza.name = "presence"
|
53
|
+
stanza.type = "subscribed"
|
54
|
+
stanza.set_attribute("to",pres.attribute("from"))
|
55
|
+
|
56
|
+
@conn.send(stanza)
|
57
|
+
|
58
|
+
#Now it's our turn to send a subscription request
|
59
|
+
stanza = StropheRuby::Stanza.new
|
60
|
+
stanza.name = "presence"
|
61
|
+
stanza.type = "subscribe"
|
62
|
+
stanza.set_attribute("to",pres.attribute("from"))
|
63
|
+
@conn.send(stanza)
|
64
|
+
end
|
63
65
|
end
|
64
66
|
|
65
67
|
#Echo every messages
|
66
68
|
@conn.add_handler("message") do |msg|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
69
|
+
body=msg.child_by_name("body")
|
70
|
+
if body
|
71
|
+
if body.text.to_s == "exit"
|
72
|
+
disconnect
|
73
|
+
else
|
74
|
+
stanza = StropheRuby::Stanza.new
|
75
|
+
stanza.name = "message"
|
76
|
+
stanza.set_attribute("to",msg.attribute("from"))
|
77
|
+
|
78
|
+
body_stanza = StropheRuby::Stanza.new
|
79
|
+
body_stanza.name="body"
|
80
|
+
|
81
|
+
text_stanza = StropheRuby::Stanza.new
|
82
|
+
text_stanza.text="I'm very happy for you"
|
83
|
+
|
84
|
+
body_stanza.add_child(text_stanza)
|
85
|
+
stanza.add_child(body_stanza)
|
86
|
+
|
87
|
+
@conn.send(stanza)
|
88
|
+
end
|
89
|
+
end
|
88
90
|
end
|
89
91
|
end
|
90
92
|
|
93
|
+
def disconnect
|
94
|
+
StropheRuby::EventLoop.stop(@ctx)
|
95
|
+
end
|
96
|
+
|
91
97
|
StropheRuby::EventLoop.prepare
|
92
98
|
|
93
99
|
@ctx = StropheRuby::Context.new(StropheRuby::Logging::DEBUG)
|
@@ -101,15 +107,10 @@ StropheRuby::EventLoop.prepare
|
|
101
107
|
announce_presence
|
102
108
|
register_callbacks
|
103
109
|
else
|
104
|
-
|
110
|
+
StropheRuby::EventLoop.stop(@ctx)
|
105
111
|
end
|
106
112
|
end
|
107
113
|
|
108
|
-
def disconnect
|
109
|
-
StropheRuby::EventLoop.stop(@ctx)
|
110
|
-
end
|
111
|
-
|
112
|
-
|
113
114
|
#This is a blocking call
|
114
115
|
StropheRuby::EventLoop.run(@ctx)
|
115
116
|
|
data/Rakefile
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
|
4
4
|
# Generate all the Rake tasks
|
5
5
|
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
6
|
-
$hoe = Hoe.new('strophe_ruby', '0.0.
|
6
|
+
$hoe = Hoe.new('strophe_ruby', '0.0.3') do |p|
|
7
7
|
p.developer('François Lamontagne', 'flamontagne@gmail.com')
|
8
8
|
p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
|
9
9
|
p.rubyforge_name = p.name # TODO this is default value
|
Binary file
|