| | |
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | DesignDebug.LogError(e.Message);
|
| | | DebugEx.LogError(e.Message);
|
| | | }
|
| | | }
|
| | |
|
| | |
| | |
|
| | | if (ipAddresses[0].AddressFamily == AddressFamily.InterNetworkV6)
|
| | | {
|
| | | DesignDebug.Log("当前使用的网络: IPV6");
|
| | | DebugEx.Log("当前使用的网络: IPV6");
|
| | | m_Socket = new Socket(AddressFamily.InterNetworkV6, SocketType.Stream, ProtocolType.Tcp);
|
| | | }
|
| | | else
|
| | | {
|
| | | DesignDebug.Log("当前使用的网络: IPV4");
|
| | | DebugEx.Log("当前使用的网络: IPV4");
|
| | | m_Socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
| | | }
|
| | |
|
| | |
| | | {
|
| | | if (!_result.IsCompleted)
|
| | | {
|
| | | DesignDebug.Log("链接超时!");
|
| | | DebugEx.Log("链接超时!");
|
| | | CloseConnect();
|
| | | }
|
| | | else
|
| | | {
|
| | | if (m_Socket != null && m_Socket.Connected)
|
| | | {
|
| | | DesignDebug.Log("确认的链接实现");
|
| | | DebugEx.Log("确认的链接实现");
|
| | | OnConnectSuccess();
|
| | |
|
| | | if (onConnected != null)
|
| | |
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | DesignDebug.Log(e);
|
| | | DebugEx.Log(e);
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | vNetpack = PackageRegedit.TransPack(vPackBytes);
|
| | | if (vNetpack != null)
|
| | | {
|
| | | if (DesignDebug.EnableNet)
|
| | | if (DebugEx.EnableNetLog)
|
| | | {
|
| | | DesignDebug.LogNetFormat("收包:{0}", vNetpack.GetType().Name);
|
| | | DebugEx.NetLogFormat("收包:{0}", vNetpack.GetType().Name);
|
| | | }
|
| | |
|
| | | GameNetSystem.Instance.PushPackage(vNetpack);
|
| | |
| | | return;
|
| | | if (vNetPack == null)
|
| | | {
|
| | | DesignDebug.LogError("要发的信息对象为空");
|
| | | DebugEx.LogError("要发的信息对象为空");
|
| | | return;
|
| | | }
|
| | |
|
| | | if (DesignDebug.EnableNet)
|
| | | if (DebugEx.EnableNetLog)
|
| | | {
|
| | | DesignDebug.LogNetFormat("发包:{0}", vNetPack.GetType().Name);
|
| | | DebugEx.NetLogFormat("发包:{0}", vNetPack.GetType().Name);
|
| | | }
|
| | |
|
| | | if (vNetPack.cmd == (ushort)0x03FE || vNetPack.cmd == (ushort)0x1801)
|
| | |
| | | {
|
| | | if (!Connected)
|
| | | {
|
| | | DesignDebug.LogError("尚未与该后端链接!无法发送信息");
|
| | | DebugEx.LogError("尚未与该后端链接!无法发送信息");
|
| | | return;
|
| | | }
|
| | | if (vBytes == null || vBytes.Length < 2)
|
| | | {
|
| | | DesignDebug.LogError("要发的信息数据为空或数据不足");
|
| | | DebugEx.LogError("要发的信息数据为空或数据不足");
|
| | | return;
|
| | | }
|
| | |
|
| | |
| | | {
|
| | | if (!Connected)
|
| | | {
|
| | | DesignDebug.LogError("尚未与该后端链接!无法发送信息");
|
| | | DebugEx.LogError("尚未与该后端链接!无法发送信息");
|
| | | return;
|
| | | }
|
| | | if (vBytes == null || vBytes.Length < 2)
|
| | | {
|
| | | DesignDebug.LogError("要发的信息数据为空或数据不足");
|
| | | DebugEx.LogError("要发的信息数据为空或数据不足");
|
| | | return;
|
| | | }
|
| | |
|
| | |
| | | }
|
| | | catch
|
| | | {
|
| | | DesignDebug.LogError("发送时发生异常");
|
| | | DebugEx.LogError("发送时发生异常");
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | }
|
| | | catch (Exception ex)
|
| | | {
|
| | | DesignDebug.Log(ex);
|
| | | DebugEx.Log(ex);
|
| | | }
|
| | |
|
| | | }
|