Revision 7d493229
Added by Marc Dequènes over 13 years ago
- ID 7d4932290d4420bd471ed3d11e8b875568e3f418
lib/cyborghood/cyborg/botnet.rb | ||
---|---|---|
"unix_socket"
|
||
end
|
||
|
||
def setup
|
||
super
|
||
@pending_conversation_close = []
|
||
end
|
||
|
||
def peer_socket(peer)
|
||
File.join(Config::RUN_DIR, peer.downcase + ".sock")
|
||
end
|
||
... | ... | |
if @comm_list.has_key? peer
|
||
block.call @comm_list[peer]
|
||
else
|
||
callback = proc do |conversation|
|
||
block.call conversation
|
||
@pending_conversation_close << conversation.peer_id
|
||
end
|
||
begin
|
||
EventMachine.connect_unix_domain(peer_socket(peer), Conversation, self, block)
|
||
rescue
|
||
... | ... | |
|
||
def unregister_communication(peer)
|
||
@comm_list.delete(peer)
|
||
@pending_conversation_close.delete(peer)
|
||
end
|
||
|
||
def ask_to_stop
|
||
... | ... | |
|
||
protected
|
||
|
||
def process_system_notification(msg)
|
||
if msg[:topic] == 'CONVERSATION IDLE'
|
||
peer = @comm_list[msg[:peer]]
|
||
return if peer.nil?
|
||
|
||
peer.bye
|
||
else
|
||
super
|
||
end
|
||
end
|
||
|
||
def ready_to_stop?
|
||
@comm_list.empty?
|
||
end
|
Also available in: Unified diff
[evol] add system/user notif to bot level and detecte when a conversation is idle, to close it after used in connect_peer() with block