internal override void WireSend()
{
DebugUtils.DebugLog("Send a Message.");
try
{
lock (sending_lock_)
{
DebugUtils.Assert(sending_.Count >= 2);
DebugUtils.DebugLog("Host Url: {0}", host_url_);
FunapiMessage header = sending_[0];
FunapiMessage body = sending_[1];
// Header
Dictionary<string, string> headers = new Dictionary<string, string>();
string str_header = ((StringBuilder)header.message).ToString();
string[] list = str_header.Split(kHeaderSeparator, StringSplitOptions.None);
for (int i = 0; i < list.Length; i += 2)
{
if (list[i].Length <= 0)
break;
if (list[i] == kEncryptionHeaderField)
headers.Add(kEncryptionHttpHeaderField, list[i+1]);
else
headers.Add(list[i], list[i+1]);
}
if (str_cookie_.Length > 0)
headers.Add(kCookieHeaderField, str_cookie_);
// Sets timeout timer
timer_.KillTimer(kTimeoutTimerId);
timer_.AddTimer(kTimeoutTimerId, kTimeoutSeconds, OnRequestTimeout, body.msg_type);
// Sending a message
#if !NO_UNITY
if (using_www_)
{
SendWWWRequest(headers, body);
}
else
#endif
{
SendHttpWebRequest(headers, body);
}
}
}
catch (Exception e)
{
last_error_code_ = ErrorCode.kSendFailed;
last_error_message_ = "Failure in WireSend: " + e.ToString();
DebugUtils.Log(last_error_message_);
AddToEventQueue(OnFailure);
}
}