检测 重连后 和服务端的 确认消息 11700 11701
parent
18642e01ae
commit
dc04060dd9
|
@ -403,7 +403,7 @@ public class SocketClient
|
|||
buffer.ReadIntToByte();
|
||||
//协议号
|
||||
int msgid = buffer.ReadIntToByte();
|
||||
|
||||
Debug.Log("[SocketClient:OnReceivedMessage]msgid:" + msgid);
|
||||
//收到心跳包
|
||||
if (msgid == 1001)
|
||||
{
|
||||
|
@ -441,13 +441,10 @@ public class SocketClient
|
|||
UnregistNetMessage(INDICATION_ERROR_CODE, Ygqmgx_indicationErrorAction);
|
||||
if (client != null)
|
||||
{
|
||||
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
client.Client.Disconnect(false);
|
||||
Debug.Log("****Socket*********************Disconnect() ---" + client.Client.Handle+ "@"+ client.Client.LocalEndPoint.ToString());
|
||||
//Debug.Log("****Socket*********************Disconnect() ---" + client.Client.Handle+ "@"+ client.Client.LocalEndPoint.ToString());
|
||||
}
|
||||
catch { }
|
||||
|
||||
|
@ -706,20 +703,22 @@ public class SocketClient
|
|||
float _LastReconectime = 0;
|
||||
public void TryReconnect()
|
||||
{
|
||||
if (Time.time - _LastReconectime < AppConst.ConnectTimeout + 1)
|
||||
if (IsConnected())
|
||||
{
|
||||
NetworkStateInfo info = new NetworkStateInfo();
|
||||
info.type = NetworkStateType.Reconnected;
|
||||
info.msg = null;
|
||||
stateInfoStack.Push(info);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Time.time - _LastReconectime < AppConst.ConnectTimeout )
|
||||
return;
|
||||
|
||||
_LastReconectime = Time.time;
|
||||
|
||||
Debug.Log("****Socket*********************TryReconnect ---" + IpAddress);
|
||||
//if (IsConnected())
|
||||
//{
|
||||
// NetworkStateInfo info = new NetworkStateInfo();
|
||||
// info.type = NetworkStateType.Reconnected;
|
||||
// info.msg = null;
|
||||
// stateInfoStack.Push(info);
|
||||
// return;
|
||||
//}
|
||||
|
||||
|
||||
|
||||
if (reconnect_co != null)
|
||||
|
@ -803,6 +802,7 @@ public class SocketClient
|
|||
|
||||
void OnReconnect(IAsyncResult result)
|
||||
{
|
||||
_LastReconectime = 0;
|
||||
m_isConnecting = false;
|
||||
|
||||
//检测是否成功的建立了链接。..
|
||||
|
@ -820,6 +820,7 @@ public class SocketClient
|
|||
outStream = client.GetStream();
|
||||
client.GetStream().BeginRead(byteBuffer, 0, MAX_READ, new AsyncCallback(OnRead), null);
|
||||
AddStateInfo(NetworkStateType.Reconnected, null);
|
||||
_LastReconectime = 0;
|
||||
Debug.Log("****Socket*********************OnReconnect SUCCESS @"+ client.Client.LocalEndPoint.ToString());
|
||||
}
|
||||
catch (Exception e)
|
||||
|
@ -861,7 +862,7 @@ public class SocketClient
|
|||
buffer.Close();
|
||||
|
||||
|
||||
//UnityEngine.Debug.Log("SocketClient.m_SendMessage..."+ msgId);
|
||||
Debug.Log("[SocketClient.m_SendMessage]..."+ msgId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
Loading…
Reference in New Issue