//udp proxy state func, register here public void OnUdpStateStateChange(GEM_NET_LIB.EClientNetWorkState a_eState, string ip, ushort port) { if (GEM_NET_LIB.EClientNetWorkState.Connected == a_eState) { Log.info(this, "[NetworkManager][OnUdpStateStateChange] Succeed to connect server"); if (null != OnUdpProxyConnectCallBack) { OnUdpProxyConnectCallBack(); } proxyStatus = NetworkDefine.NetworkStatus.Connected; //SendUdpRegiterRequest(); } else if (GEM_NET_LIB.EClientNetWorkState.DisConnected == a_eState) { Log.info(this, "[NetworkManager][OnUdpStateStateChange] Udp proxy-server loses connection"); if (null != OnUdpProxyDisConnectCallBack) { OnUdpProxyDisConnectCallBack(); } proxyStatus = NetworkDefine.NetworkStatus.Disconnected; } else { //nothing to do } Log.info(this, "[NetworkManager][OnUdpStateStateChange] EClientNetWorkState " + a_eState.ToString()); }
public void OnConnectStateChange(GEM_NET_LIB.EClientNetWorkState a_eState, string ip, ushort port, Exception e) { if (GEM_NET_LIB.EClientNetWorkState.Connected == a_eState) { Log.info(this, "[NetworkManager][OnConnectStateChange] Succeed to connect server"); status = NetworkDefine.NetworkStatus.Connected; if (null != OnConnectScuessCallBack) { OnConnectScuessCallBack(); } //TODO...Start by config... //HeartBeatController.Instance.StartHeartBeat(); _connectCount++; /* * if(bInReconnectingProcesss == true && _connectCount > 1) * { * SendReConnectRequest(); * }*/ //TODO:只有第一次连接需要发送first bytes..... /* * if (_connectCount == 1) { * C2S_SendFirstBytes.SendFirstByte (); * }*/ } else if (GEM_NET_LIB.EClientNetWorkState.Connecting == a_eState) { Log.info(this, "[NetworkManager][OnConnectStateChange] Begin connecting"); } else { Log.error(this, "[NetworkManager][OnConnectStateChange] Failed to connect server, inner state : " + a_eState + " Exception: " + e); if (bInReconnectingProcesss == true) { //PopMessage.Create("服务器连接失败,尝试重连..."); Log.error(this, "服务器连接失败,尝试重连..."); return; } else { if (status == NetworkDefine.NetworkStatus.Failed) { Log.error(this, "您已断开连接=================!"); /* * MsgBox mbx = DialogBoxManager.GetInstance().MsgBox("您已断开连接", "提示") as MsgBox; * if(OnReconnectFailCallback != null) * OnReconnectFailCallback(); * mbx.Btn_YesOnClick = ()=>{ * Application.Quit(); * };*/ Stop(); return; } else { //PopMessage.Create("网络连接不稳定"); Log.error(this, "网络连接不稳定......"); } } /*status = NetworkDefine.NetworkStatus.Failed;*/ if (null != OnConnectFalseCallBack) { OnConnectFalseCallBack(); } } /* * Engine.Core.EventDispatcher.Instance.DispatchEvent( * new Engine.Core.NetworkEvent() * { * errorType = a_eState, * connectCount = _connectCount, * });*/ Log.info(this, "[NetworkManager][OnConnectStateChange] EClientNetWorkState " + a_eState.ToString()); }