cirrocumulus 0.9.8 → 0.9.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/cirrocumulus/channels.rb +5 -8
- data/lib/cirrocumulus/channels/jabber.rb +17 -12
- data/lib/cirrocumulus/ontology.rb +1 -1
- metadata +2 -2
@@ -123,14 +123,11 @@ class NetworkChannel < AbstractChannel
|
|
123
123
|
attr_reader :serializer
|
124
124
|
|
125
125
|
def build_message(receiver_name, act, content, options)
|
126
|
-
msg = [
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
[:content, content]
|
132
|
-
]
|
133
|
-
|
126
|
+
msg = [act]
|
127
|
+
msg << [:receiver, [:agent_identifier, :name, receiver_name]] if receiver_name
|
128
|
+
msg << [:reply_to, [:agent_identifier, :name, options[:reply_to]]] if options.has_key?(:reply_to)
|
129
|
+
msg << [:content, content]
|
130
|
+
msg << [:ontology, options[:ontology]] if options.has_key?(:ontology)
|
134
131
|
msg << [:reply_with, options[:reply_with]] if options.has_key?(:reply_with)
|
135
132
|
msg << [:in_reply_to, options[:in_reply_to]] if options.has_key?(:in_reply_to)
|
136
133
|
msg << [:conversation_id, options[:conversation_id]] if options.has_key?(:conversation_id)
|
@@ -18,7 +18,7 @@ class JabberIdentifier < RemoteIdentifier
|
|
18
18
|
while true
|
19
19
|
msg = @channel.received_messages.pop(true) rescue nil
|
20
20
|
break if msg.nil?
|
21
|
-
|
21
|
+
|
22
22
|
begin
|
23
23
|
fipa_message = parser.parse_string(msg.body)
|
24
24
|
id = RemoteIdentifier.new(msg.from.resource)
|
@@ -38,16 +38,20 @@ class JabberIdentifier < RemoteIdentifier
|
|
38
38
|
options = {}
|
39
39
|
content.each do |parameter|
|
40
40
|
next if !parameter.is_a?(Array) || parameter.size < 1
|
41
|
+
|
41
42
|
if parameter[0] == :receiver
|
42
43
|
receiver = parameter[1][2]
|
43
44
|
elsif parameter[0] == :content
|
44
45
|
action_content = parameter[1]
|
45
|
-
elsif [:reply_with, :in_reply_to, :conversation_id].include?(parameter[0])
|
46
|
+
elsif [:ontology, :reply_with, :in_reply_to, :conversation_id].include?(parameter[0])
|
46
47
|
options[parameter[0]] = parameter[1]
|
48
|
+
elsif parameter[0] == :reply_to
|
49
|
+
|
47
50
|
end
|
48
51
|
end
|
49
|
-
|
50
|
-
next if
|
52
|
+
|
53
|
+
next if options.has_key?(:ontology) && options[:ontology] != instance.name
|
54
|
+
next if !options.has_key?(:ontology) && (receiver.nil? || receiver != @jid)
|
51
55
|
|
52
56
|
case act
|
53
57
|
when :query
|
@@ -142,8 +146,8 @@ class JabberChannel
|
|
142
146
|
client.close()
|
143
147
|
@jabber = Jabber::Simple.new(@full_jid, @@password)
|
144
148
|
rescue Exception => ex
|
145
|
-
|
146
|
-
|
149
|
+
Log4r::Logger['channels::jabber'].fatal('Failed to register new account or connect.')
|
150
|
+
Log4r::Logger['channels::jabber'].fatal("Received exception: #{ex.to_s}")
|
147
151
|
return false
|
148
152
|
end
|
149
153
|
|
@@ -165,22 +169,23 @@ class JabberChannel
|
|
165
169
|
|
166
170
|
def tick()
|
167
171
|
return if !connected?
|
168
|
-
|
172
|
+
|
169
173
|
@jabber.received_messages do |msg|
|
170
|
-
|
171
|
-
|
172
|
-
@recv_q << msg
|
174
|
+
next unless msg.x('jabber:x:delay').nil?
|
175
|
+
@recv_q << msg
|
173
176
|
end
|
174
177
|
|
175
178
|
while true do
|
176
179
|
to_send = @send_q.pop(true) rescue nil
|
177
180
|
break if to_send.nil?
|
178
|
-
|
179
|
-
@jabber.send!('<message type="groupchat" to="%s" id="%s"><body>%s</body></message>' % [
|
181
|
+
|
182
|
+
@jabber.send!('<message type="groupchat" to="%s" id="%s"><body>%s</body></message>' % [
|
180
183
|
"%s@conference.%s" % [@conference, @server], Guid.new.to_s.gsub('-', ''),
|
181
184
|
to_send.gsub('&', '&').gsub('<', '<').gsub('>', '>').gsub('"', '"')
|
182
185
|
])
|
183
186
|
end
|
187
|
+
rescue Exception => ex
|
188
|
+
Log4r::Logger['channels::jabber'].warn(ex.to_s)
|
184
189
|
end
|
185
190
|
|
186
191
|
protected
|
@@ -370,7 +370,7 @@ class Ontology
|
|
370
370
|
# Handles query-if to ontology. By default, it lookups the fact in KB and replies to the sender.
|
371
371
|
#
|
372
372
|
def handle_query_if(sender, proposition, options = {})
|
373
|
-
|
373
|
+
info "%25s | %s queries if %s %s" % [identifier, sender, Sexpistol.new.to_sexp(proposition), print_message_options(options)] unless handle_saga_reply(sender, :query, expression, options)
|
374
374
|
end
|
375
375
|
|
376
376
|
protected
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cirrocumulus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.9
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-12-
|
12
|
+
date: 2012-12-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: log4r
|