Project

General

Profile

« Previous | Next » 

Revision 476368e8

Added by Marc Dequènes about 14 years ago

  • ID 476368e89610c1079a6a5c869254f3958533484d

[fix] adapted Interface to recent changes, pass bot object, and correct api_methods() calculation

View differences:

bin/mapmaker
include CyborgServerInterface
include CyborgServerRootInterfaceAddon
export_method :toto
class Taiste
include CyborgServerInterface
......
api_methods
end
stateful_dynamic_interface("dns/zones/#NODE#") {|node_name| DnsZone.new(node_name) }
stateful_dynamic_interface("DnsZone/#NODE#") {|node_name| DnsZone.new(node_name) }
end
end
end
bin/mapmaker_client
if conv
logger.info "Yo ! Conversation ready with MapMaker (#{conv.peer_name}) !"
conv.thread("plop") do |conv_thread|
conv.protocol.send_request_call(conv_thread, "/coucou") do |reply|
conv.protocol.send_request_call(conv_thread, "/api_version") do |reply|
pp reply
end
end
lib/cyborghood/base/config.rb
CONFFILE_GLOBAL = "cyborghood.conf"
CONFFILE_BOT = "cyborghood_%s.conf"
attr_accessor :bot_id
def self.load(name = nil)
# load all config parts
g_config_raw = load_config_raw()
lib/cyborghood/cyborg/botnet_server.rb
raise CyberError.new(:unrecoverable, "config", "Unknown botnet connection type")
end
end
def setup
super
self.interface.bot = self
end
end
end
lib/cyborghood/cyborg/interface.rb
module CyborgServerInterfaceBase
NODE_PATTERN = "((?:\/|(?:\/[a-zA-Z0-9._]+)+[?=]?))"
attr_accessor :bot
def self.included(base)
base.extend(ClassMethods)
end
......
end
def api_methods
methods = self.class.exported_methods
methods = []
methods += self.class.public_instance_methods(false) if self.class.auto_export_public_instance_methods
methods -= ["initialize", "__destroy", "method_missing"]
methods & self.methods
methods &= self.methods
methods += self.class.exported_methods
end
def api_container_methods
......
# additional mixin
module CyborgServerRootInterfaceAddon
PROTOCOL_VERSION = "0.1~"
API_VERSION = "0.1~"
def self.included(base)
list = self.public_instance_methods(false)
base.class_eval do
export_method list
export_method *list
end
end
......
VERSION
end
def protocol_version
PROTOCOL_VERSION
def api_version
API_VERSION
end
def bot_name
@config.bot_name
@bot.name
end
end
end

Also available in: Unified diff