c3s 0.3.6 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest +1 -0
- data/Rakefile +1 -1
- data/c3s.gemspec +3 -3
- data/lib/component.rb +8 -11
- data/lib/component_connection.rb +2 -0
- data/lib/pubsub/publisher.rb +4 -2
- metadata +5 -5
data/Manifest
CHANGED
data/Rakefile
CHANGED
data/c3s.gemspec
CHANGED
@@ -2,15 +2,15 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{c3s}
|
5
|
-
s.version = "0.
|
5
|
+
s.version = "0.4.0"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Ricardo Otero"]
|
9
|
-
s.date = %q{2010-04-
|
9
|
+
s.date = %q{2010-04-23}
|
10
10
|
s.description = %q{C3s library gem.}
|
11
11
|
s.email = %q{oterosantos@gmail.com}
|
12
12
|
s.extra_rdoc_files = ["README.rdoc", "lib/c3s.rb", "lib/c3s_logger.rb", "lib/component.rb", "lib/component_connection.rb", "lib/configreader.rb", "lib/databaseadapter.rb", "lib/model.rb", "lib/pubsub/node.rb", "lib/pubsub/nodetracker.rb", "lib/pubsub/publisher.rb", "lib/pubsub/subscriber.rb", "lib/republisher.rb"]
|
13
|
-
s.files = ["README.rdoc", "Rakefile", "
|
13
|
+
s.files = ["README.rdoc", "Rakefile", "lib/c3s.rb", "lib/c3s_logger.rb", "lib/component.rb", "lib/component_connection.rb", "lib/configreader.rb", "lib/databaseadapter.rb", "lib/model.rb", "lib/pubsub/node.rb", "lib/pubsub/nodetracker.rb", "lib/pubsub/publisher.rb", "lib/pubsub/subscriber.rb", "lib/republisher.rb", "Manifest", "c3s.gemspec"]
|
14
14
|
s.homepage = %q{http://github.com/rikas/c3s}
|
15
15
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "C3s", "--main", "README.rdoc"]
|
16
16
|
s.require_paths = ["lib"]
|
data/lib/component.rb
CHANGED
@@ -42,26 +42,20 @@ module C3s
|
|
42
42
|
end
|
43
43
|
|
44
44
|
##
|
45
|
-
#
|
45
|
+
# Adds callbacks to listen for
|
46
46
|
# provides a callback named *handle_iq* for especific components
|
47
47
|
# to use.
|
48
|
-
def
|
49
|
-
super
|
50
|
-
|
51
|
-
Thread.abort_on_exception = true
|
52
|
-
|
48
|
+
def add_callbacks
|
53
49
|
add_iq_callback do |iq|
|
54
50
|
t1 = Thread.new do
|
55
51
|
handle_iq(iq)
|
56
52
|
end
|
57
|
-
t1.join
|
58
53
|
end
|
59
54
|
|
60
55
|
add_message_callback do |msg|
|
61
56
|
t2 = Thread.new do
|
62
57
|
handle_msg(msg)
|
63
58
|
end
|
64
|
-
t2.join
|
65
59
|
end
|
66
60
|
end
|
67
61
|
|
@@ -94,6 +88,7 @@ module C3s
|
|
94
88
|
# Handles discovery, sets and gets
|
95
89
|
# iq:: [Jabber::IQ] the received IQ packet
|
96
90
|
def handle_iq(iq)
|
91
|
+
$LOG.info "Got an iq: #{iq.id}"
|
97
92
|
if iq.query.kind_of?(Jabber::Discovery::IqQueryDiscoInfo)
|
98
93
|
handle_disco_info(iq)
|
99
94
|
elsif iq.query.first_element(config['name']) # TODO assuming that pubsubnode = xml root
|
@@ -141,7 +136,7 @@ module C3s
|
|
141
136
|
if object.errors.count == 0
|
142
137
|
$LOG.info "Publishing data to node #{config['name']}:#{data[:jid]} (data changed: #{changed})"
|
143
138
|
c3snode = C3s::Node.new("#{config['name']}:#{data[:jid]}")
|
144
|
-
|
139
|
+
self.publish_to_pubsub(c3snode, stanza, changed)
|
145
140
|
send_ok(iq)
|
146
141
|
end
|
147
142
|
|
@@ -191,7 +186,7 @@ module C3s
|
|
191
186
|
# c3snode:: [C3s::Node] the pubsub node
|
192
187
|
# data:: [String] what to publish
|
193
188
|
# changed:: [Boolean] the data is different from last set operation?
|
194
|
-
def
|
189
|
+
def publish_to_pubsub(c3snode, data, changed)
|
195
190
|
if changed
|
196
191
|
$LOG.info "Information for node '#{c3snode.to_s}' changed. Publishing data..."
|
197
192
|
pub = Publisher.new(self, config['pubsub'])
|
@@ -199,7 +194,9 @@ module C3s
|
|
199
194
|
pub.publish(c3snode, data)
|
200
195
|
end
|
201
196
|
|
202
|
-
|
197
|
+
send_ok(iq) if iq.is_a?(Jabber::Iq)
|
198
|
+
rescue Exception => e
|
199
|
+
$LOG.error("#{e.inspect} #{e.backtrace.join("\n")}")
|
203
200
|
end
|
204
201
|
|
205
202
|
##
|
data/lib/component_connection.rb
CHANGED
data/lib/pubsub/publisher.rb
CHANGED
@@ -96,6 +96,8 @@ module C3s
|
|
96
96
|
item = Jabber::PubSub::Item.new
|
97
97
|
item.add(content)
|
98
98
|
@pubsub.publish_item_to(c3snode.to_s, item)
|
99
|
+
rescue Exception => e
|
100
|
+
$LOG.error("#{e.inspect} #{e.backtrace.join("\n")}")
|
99
101
|
end
|
100
102
|
|
101
103
|
##
|
@@ -108,8 +110,8 @@ module C3s
|
|
108
110
|
nodebrowser.get_info(@service, name)
|
109
111
|
NodeTracker.add_node(name)
|
110
112
|
true
|
111
|
-
rescue Jabber::ServerError =>
|
112
|
-
return false if
|
113
|
+
rescue Jabber::ServerError => e
|
114
|
+
return false if e.to_s.include?("item-not-found")
|
113
115
|
end
|
114
116
|
end
|
115
117
|
end
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 0.
|
7
|
+
- 4
|
8
|
+
- 0
|
9
|
+
version: 0.4.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Ricardo Otero
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-04-
|
17
|
+
date: 2010-04-23 00:00:00 +01:00
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|
@@ -41,7 +41,6 @@ extra_rdoc_files:
|
|
41
41
|
files:
|
42
42
|
- README.rdoc
|
43
43
|
- Rakefile
|
44
|
-
- c3s.gemspec
|
45
44
|
- lib/c3s.rb
|
46
45
|
- lib/c3s_logger.rb
|
47
46
|
- lib/component.rb
|
@@ -55,6 +54,7 @@ files:
|
|
55
54
|
- lib/pubsub/subscriber.rb
|
56
55
|
- lib/republisher.rb
|
57
56
|
- Manifest
|
57
|
+
- c3s.gemspec
|
58
58
|
has_rdoc: true
|
59
59
|
homepage: http://github.com/rikas/c3s
|
60
60
|
licenses: []
|