SocketClient .OnReconnect Bug.fix
parent
119a64143a
commit
0b72d3a042
|
|
@ -11583,8 +11583,8 @@ MonoBehaviour:
|
||||||
size: 1244
|
size: 1244
|
||||||
- id: 2893
|
- id: 2893
|
||||||
fileName: lzma/luabytes.unity3d
|
fileName: lzma/luabytes.unity3d
|
||||||
crc: 993108505
|
crc: 2306403141
|
||||||
size: 6098678
|
size: 6100161
|
||||||
- id: 2894
|
- id: 2894
|
||||||
fileName: lzma/resconfigs.unity3d
|
fileName: lzma/resconfigs.unity3d
|
||||||
crc: 4059228276
|
crc: 4059228276
|
||||||
|
|
|
||||||
|
|
@ -912,8 +912,8 @@ MonoBehaviour:
|
||||||
settingInfo:
|
settingInfo:
|
||||||
logLevel: 0
|
logLevel: 0
|
||||||
isDebug: 0
|
isDebug: 0
|
||||||
bundleMode: 0
|
bundleMode: 1
|
||||||
luaBundleMode: 0
|
luaBundleMode: 1
|
||||||
isUpdate: 0
|
isUpdate: 0
|
||||||
isSDK: 0
|
isSDK: 0
|
||||||
isSDKLogin: 0
|
isSDKLogin: 0
|
||||||
|
|
|
||||||
|
|
@ -132,10 +132,8 @@ public class SocketClient
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Connect()
|
public void Connect()
|
||||||
{
|
{
|
||||||
|
|
||||||
//Debug.Log("****Socket*********************Connect ---" + IpAddress);
|
//Debug.Log("****Socket*********************Connect ---" + IpAddress);
|
||||||
Close();
|
Close();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var ipType = GetIPAddressType(IpAddress);
|
var ipType = GetIPAddressType(IpAddress);
|
||||||
|
|
@ -354,7 +352,7 @@ public class SocketClient
|
||||||
/// <param name="ms"></param>
|
/// <param name="ms"></param>
|
||||||
void OnReceivedMessage(ByteBuffer buffer)
|
void OnReceivedMessage(ByteBuffer buffer)
|
||||||
{
|
{
|
||||||
MixCode.Command_Switch(13);
|
MixCode.Command_Switch(13);
|
||||||
//user id
|
//user id
|
||||||
buffer.ReadIntToByte();
|
buffer.ReadIntToByte();
|
||||||
//token
|
//token
|
||||||
|
|
@ -633,15 +631,6 @@ public class SocketClient
|
||||||
float _LastReconectime = 0;
|
float _LastReconectime = 0;
|
||||||
public void TryReconnect()
|
public void TryReconnect()
|
||||||
{
|
{
|
||||||
//if (m_isConnecting)
|
|
||||||
// return;
|
|
||||||
|
|
||||||
if (client != null && client.Connected)
|
|
||||||
{
|
|
||||||
_DoReconnected();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Time.time - _LastReconectime < AppConst.ConnectTimeout+1)
|
if (Time.time - _LastReconectime < AppConst.ConnectTimeout+1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
@ -735,27 +724,30 @@ public class SocketClient
|
||||||
void OnReconnect(IAsyncResult result)
|
void OnReconnect(IAsyncResult result)
|
||||||
{
|
{
|
||||||
m_isConnecting = false;
|
m_isConnecting = false;
|
||||||
if (!client.Connected)
|
|
||||||
|
//检测是否成功的建立了链接。..
|
||||||
|
if (client==null || !client.Connected)
|
||||||
{
|
{
|
||||||
Debug.Log("****Socket*********************OnReconnect FAILED ---" + IpAddress);
|
Debug.Log("****Socket*********************OnReconnect FAILED ---" + IpAddress);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Debug.Log("****Socket*********************OnReconnect SUCCESS ---" + IpAddress);
|
try
|
||||||
|
|
||||||
WAIT.AddWait(1f).Wait(()=>
|
|
||||||
{
|
{
|
||||||
_DoReconnected();
|
//完成本次链接
|
||||||
});
|
client.EndConnect(result);
|
||||||
|
|
||||||
|
// 记录链接的成功事件。
|
||||||
|
outStream = client.GetStream();
|
||||||
|
client.GetStream().BeginRead(byteBuffer, 0, MAX_READ, new AsyncCallback(OnRead), null);
|
||||||
|
AddStateInfo(NetworkStateType.Reconnected, null);
|
||||||
|
Debug.Log("****Socket*********************OnReconnect SUCCESS ---" + IpAddress);
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
Debug.Log("****Socket*********************OnReconnect FAILED ---" + e.Message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _DoReconnected()
|
|
||||||
{
|
|
||||||
Debug.Log("****Socket*********************AddStateInfo NetworkStateType.Reconnected-" + IpAddress);
|
|
||||||
outStream = client.GetStream();
|
|
||||||
client.GetStream().BeginRead(byteBuffer, 0, MAX_READ, new AsyncCallback(OnRead), null);
|
|
||||||
AddStateInfo(NetworkStateType.Reconnected, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 发送消息
|
/// 发送消息
|
||||||
|
|
|
||||||
|
|
@ -88,19 +88,20 @@ function Network:OnReconnect()
|
||||||
|
|
||||||
|
|
||||||
self.socket:SendMessageWithCallBack(MessageTypeProto_pb.RECONNECT_REQUEST, MessageTypeProto_pb.RECONNECT_RESPONSE, nil, function(b)
|
self.socket:SendMessageWithCallBack(MessageTypeProto_pb.RECONNECT_REQUEST, MessageTypeProto_pb.RECONNECT_RESPONSE, nil, function(b)
|
||||||
-- Log("已经重连!!")
|
Log("已经重连!!")
|
||||||
-- RequestPanel.Hide()
|
RequestPanel.Hide()
|
||||||
-- self.isConnected = true
|
self.isConnected = true
|
||||||
-- self.bIsStartListenHeartBeat = true
|
self.bIsStartListenHeartBeat = true
|
||||||
-- Game.GlobalEvent:DispatchEvent(Protocal.Connect, self)
|
Game.GlobalEvent:DispatchEvent(Protocal.Connect, self)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
Log("已经重连!!")
|
coroutine.start(function()
|
||||||
RequestPanel.Hide()
|
coroutine.wait(2)
|
||||||
self.isConnected = true
|
Log("没有收到 重连信息,重新设置链接!!")
|
||||||
self.bIsStartListenHeartBeat = true
|
if not self.isConnected then
|
||||||
Game.GlobalEvent:DispatchEvent(Protocal.Connect, self)
|
self.socket:Disconnect()
|
||||||
|
end
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Network:Reset()
|
function Network:Reset()
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
{"subChannel":"1", "buglyId":"261348dcd3", "channel":"pc", "resUrl":"http://60.1.1.12/jieling_dl/dev/assetBundles/subChannal094-test/", "packageVersion":"0.2", "version":"0.15.0", "serverUrl":"http://60.1.1.23:8080/"}
|
{"buglyId":"261348dcd3", "channel":"pc", "resUrl":"http://60.1.1.12/jieling_dl/dev/assetBundles/subChannal094-test/", "packageVersion":"0.2", "subChannel":"1", "version":"0.15.0", "serverUrl":"http://60.1.1.23:8080/"}
|
||||||
|
|
@ -120,7 +120,7 @@ PlayerSettings:
|
||||||
16:10: 1
|
16:10: 1
|
||||||
16:9: 1
|
16:9: 1
|
||||||
Others: 1
|
Others: 1
|
||||||
bundleVersion: 0.1F
|
bundleVersion: 0.1G
|
||||||
preloadedAssets: []
|
preloadedAssets: []
|
||||||
metroInputSource: 0
|
metroInputSource: 0
|
||||||
wsaTransparentSwapchain: 0
|
wsaTransparentSwapchain: 0
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue