Revision 3d653143
Added by Marc Dequènes over 13 years ago
- ID 3d6531438e6a06725813d9635002e83d9b0e6444
lib/cyborghood/cyborg/server.rb | ||
---|---|---|
class BotServer
|
||
private_class_method :new
|
||
|
||
attr_reader :interface
|
||
|
||
def self.build(interface)
|
||
case Config.instance.botnet.connection_type
|
||
when 'unix_socket'
|
||
... | ... | |
@interface = interface
|
||
|
||
@config = Config.instance
|
||
|
||
@comm_list = {}
|
||
end
|
||
|
||
def run
|
||
... | ... | |
end
|
||
|
||
def stop
|
||
@comm_list.values.each {|conv| conv.bye }
|
||
EventMachine.stop
|
||
end
|
||
|
||
# used to quit properly and later to reuse communication channels
|
||
def register_communication(peer, conversation)
|
||
@comm_list[peer] = conversation
|
||
end
|
||
|
||
def unregister_communication(peer)
|
||
@comm_list.delete(peer)
|
||
end
|
||
end
|
||
|
||
class BotServerUNIXSocket < BotServer
|
||
... | ... | |
|
||
def run
|
||
super do
|
||
EventMachine.start_unix_domain_server(@socket, ConversationUNIXSocket, @interface)
|
||
EventMachine.start_unix_domain_server(@socket, ConversationUNIXSocket, self)
|
||
end
|
||
end
|
||
|
Also available in: Unified diff
[evol] conversation/bot protocol rework §5 (refs #30)