Revision 8f6f45f7
Added by Marc Dequènes over 13 years ago
- ID 8f6f45f7b7fcaba40dd0a82c67e1e0ad7cde4dd7
lib/cyborghood/cyborg/conversation.rb | ||
---|---|---|
MAXIMUM_LINES = 1024
|
||
|
||
attr_reader :bot, :peer_name, :peer_capabilities, :protocol
|
||
attr_reader :system_notification, :user_notification
|
||
|
||
def initialize(bot, block = nil)
|
||
@bot = bot
|
||
... | ... | |
@split_data_mode = false
|
||
@split_data_message = nil
|
||
@split_data = []
|
||
@comm_stop = false
|
||
|
||
# associated conversation threads
|
||
@conv_threads = {}
|
||
... | ... | |
@peer_name = nil
|
||
@peer_capabilities = []
|
||
|
||
@comm_stop = false
|
||
@system_notification = EventMachine::Channel.new
|
||
@user_notification = EventMachine::Channel.new
|
||
|
||
@protocol = BotProtocol.new(self)
|
||
|
||
@pending_thread_close = Set.new
|
||
@system_notification_processing = @protocol.system_notification.subscribe do |msg|
|
||
@system_notification_processing = @system_notification.subscribe do |msg|
|
||
process_system_notification(msg)
|
||
end
|
||
end
|
||
... | ... | |
logger.debug "Received data [#{identifier}]: #{data}"
|
||
|
||
if data =~ Regexp.new(ACTION_PATTERN)
|
||
# TODO: pass peer_name into Message and use it in Protocol to check replies match
|
||
peer_name = $1
|
||
conv_thread_id = $2.to_i
|
||
action_id = $3.to_i
|
||
... | ... | |
|
||
def set_comm_stop(peer_left = false)
|
||
@comm_stop = true
|
||
@protocol.system_notification.unsubscribe(@system_notification_processing)
|
||
@system_notification.unsubscribe(@system_notification_processing)
|
||
yield if block_given?
|
||
peer_left ? close_connection : close_connection_after_writing
|
||
end
|
Also available in: Unified diff
[evol] move notification from Protocol to Conversation