Revision 8c18bc9a
Added by Marc Dequènes over 13 years ago
- ID 8c18bc9aff8959ed4d8687094cf72b9b02f9bbd7
lib/cyborghood/cyborg/conversation.rb | ||
---|---|---|
@comm_stop = false
|
||
|
||
@protocol = BotProtocol.new(self)
|
||
|
||
@pending_thread_close = []
|
||
@system_notification_processing = @protocol.system_notification.subscribe do |msg|
|
||
process_system_notification(msg)
|
||
end
|
||
end
|
||
|
||
def post_init
|
||
... | ... | |
|
||
def set_comm_stop(peer_left = false)
|
||
@comm_stop = true
|
||
@protocol.system_notification.unsubscribe(@system_notification_processing)
|
||
yield if block_given?
|
||
peer_left ? close_connection : close_connection_after_writing
|
||
end
|
||
... | ... | |
th = @conv_threads[name] || new_thread(name)
|
||
if block_given?
|
||
yield th
|
||
# TODO: wait for end of chat
|
||
close_thread(name)
|
||
|
||
# wait for end of chat
|
||
@pending_thread_close << name
|
||
else
|
||
th
|
||
end
|
||
... | ... | |
def identifier
|
||
"#{@bot.identifier_prefix}/#{@signature}"
|
||
end
|
||
|
||
def process_system_notification(msg)
|
||
return unless msg[:topic] == 'THREAD IDLE'
|
||
|
||
th_name = msg[:thread]
|
||
close_thread(th_name) if @pending_thread_close.include? th_name
|
||
end
|
||
end
|
||
end
|
Also available in: Unified diff
[evol] internal notification when thread is idle allowed to mark thread closing pending