Revision 69a12fdb
Added by Marc Dequènes about 14 years ago
- ID 69a12fdbdbd27a5673fa8b848b4a03c2aa671004
lib/cyborghood/cyborg/interface.rb | ||
---|---|---|
def export_parent_methods
|
||
self.export_method *self.superclass.public_instance_methods(false)
|
||
end
|
||
|
||
def is_node?(node)
|
||
(node =~ NODE_PATTERN) ? true : false
|
||
end
|
||
end
|
||
|
||
def initialize(*args)
|
||
... | ... | |
self.class.auto_export_public_instance_methods = true
|
||
end
|
||
|
||
# convenience method
|
||
def is_node?(node)
|
||
self.class.is_node?(node)
|
||
end
|
||
|
||
def api_klasses
|
||
list = self.class.constants.collect do |c|
|
||
cc = self.class.const_get(c)
|
||
... | ... | |
# preliminary incoming message handling
|
||
def call(session, cmd, data)
|
||
action = find_node_action(session, cmd)
|
||
return "551 unknown node" if action.nil?
|
||
raise "unknown node" if action.nil?
|
||
|
||
if data.nil?
|
||
formated_data = []
|
||
else
|
||
begin
|
||
formated_data = YAML.load(data) unless data.nil?
|
||
rescue
|
||
return "552 unreadable YAML data for arguments"
|
||
end
|
||
|
||
return "552 wrong format for arguments" unless formated_data.is_a? Array
|
||
end
|
||
raise "wrong format for arguments" unless data.is_a? Array
|
||
|
||
begin
|
||
# preliminary outgoing message handling
|
||
action.call(*formated_data).to_yaml
|
||
action.call(*data)
|
||
rescue
|
||
logger.debug "node action error message: " + $!
|
||
logger.debug "node action error backtrace: " + $!.backtrace.join("\n")
|
||
return "550 method call failed: " + $!
|
||
raise "method call failed: " + $!
|
||
end
|
||
end
|
||
end
|
Also available in: Unified diff
[evol] conversation/bot protocol rework §6 (refs #30)