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 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
- == FEATURES/PROBLEMS:
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
- if pres.type == "subscribe"
46
-
47
- #We accept everyone
48
- stanza = StropheRuby::Stanza.new
49
- stanza.name = "presence"
50
- stanza.type = "subscribed"
51
- stanza.set_attribute("to",pres.attribute("from"))
52
-
53
- @conn.send(stanza)
54
-
55
- #Now it's our turn to send a subscription request
56
- stanza = StropheRuby::Stanza.new
57
- stanza.name = "presence"
58
- stanza.type = "subscribe"
59
- stanza.set_attribute("to",pres.attribute("from"))
60
- @conn.send(stanza)
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
- body=msg.child_by_name("body")
68
- if body
69
- if body.text.to_s == "exit"
70
- disconnect
71
- else
72
- stanza = StropheRuby::Stanza.new
73
- stanza.name = "message"
74
- stanza.set_attribute("to",msg.attribute("from"))
75
-
76
- body_stanza = StropheRuby::Stanza.new
77
- body_stanza.name="body"
78
-
79
- text_stanza = StropheRuby::Stanza.new
80
- text_stanza.text="I'm very happy for you"
81
-
82
- body_stanza.add_child(text_stanza)
83
- stanza.add_child(body_stanza)
84
-
85
- @conn.send(stanza)
86
- end
87
- end
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
- StropheRuby::EventLoop.stop(@ctx)
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.2') do |p|
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: strophe_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - "Fran\xC3\xA7ois Lamontagne"