Project

General

Profile

« Previous | Next » 

Revision 042b11ea

Added by Marc Dequènes almost 14 years ago

  • ID 042b11ea0ef7d3fd3acfe61f12b153f3e5a58502

[evol] Conversation: ensure Message is sent in one block in order to allow asynchronous replies on the same thread

View differences:

lib/cyborghood/cyborg/botnet/conversation.rb
require 'cyborghood/cyborg/botnet/session'
require 'cyborghood/cyborg/botnet/protocol'
require 'set'
require 'thread'
module CyborgHood
......
@config = Config.instance
@message_send = Mutex.new
@error_count = 0
@split_data_mode = false
@split_data_message = nil
......
flags = ""
flags += "+" unless message.action_parameters.nil?
send_line sprintf("%s-%04d-%04d%s %s", @bot.name, message.conv_thread.id, message.action_id, flags, message.action_code)
unless message.action_parameters.nil?
message.action_parameters.to_yaml.each_line {|l| send_line l }
send_line EOD
@message_send.synchronize do
send_line sprintf("%s-%04d-%04d%s %s", @bot.name, message.conv_thread.id, message.action_id, flags, message.action_code)
unless message.action_parameters.nil?
message.action_parameters.to_yaml.each_line {|l| send_line l }
send_line EOD
end
end
check_idle_thread(message.conv_thread)

Also available in: Unified diff