public override void OnConnectionEvent(object sender, SocketConnectionEvent e) { base.OnConnectionEvent(sender, e); switch (e) { case SocketConnectionEvent.Disconnected: if (Program.GameEngine != null) { Program.GameEngine.IsConnected = false; } Program.GameMess.Warning("You have been disconnected from server."); break; case SocketConnectionEvent.Connected: if (Program.GameEngine != null) { Program.GameEngine.IsConnected = true; } break; case SocketConnectionEvent.Reconnected: if (Program.GameEngine != null) { Program.GameEngine.IsConnected = true; Program.GameEngine.Resume(); } Program.GameMess.System("You have reconnected"); break; default: throw new ArgumentOutOfRangeException("e"); } }
public override void OnConnectionEvent(object sender, SocketConnectionEvent e) { base.OnConnectionEvent(sender, e); switch (e) { case SocketConnectionEvent.Disconnected: if (Program.GameEngine != null) Program.GameEngine.IsConnected = false; Program.GameMess.Warning("You have been disconnected from server."); break; case SocketConnectionEvent.Connected: if (Program.GameEngine != null) Program.GameEngine.IsConnected = true; break; case SocketConnectionEvent.Reconnected: if (Program.GameEngine != null) { Program.GameEngine.IsConnected = true; Program.GameEngine.Resume(); } Program.GameMess.System("You have reconnected"); break; default: throw new ArgumentOutOfRangeException("e"); } }
public override void OnConnectionEvent(object sender, SocketConnectionEvent e) { base.OnConnectionEvent(sender, e); switch (e) { case SocketConnectionEvent.Disconnected: if (Program.GameEngine != null) { Program.GameEngine.IsConnected = false; } if (Program.Dispatcher != null) { Program.Dispatcher.Invoke(new Action <string>(Program.TraceWarning), "You have been disconnected from server."); } else { Program.TraceWarning("You have been disconnected from server."); } break; case SocketConnectionEvent.Connected: if (Program.GameEngine != null) { Program.GameEngine.IsConnected = true; } break; case SocketConnectionEvent.Reconnected: if (Program.GameEngine != null) { Program.GameEngine.IsConnected = true; Program.GameEngine.Resume(); } if (Program.Dispatcher != null) { Program.Dispatcher.Invoke( new Action( () => Program.Trace.TraceEvent( TraceEventType.Information, EventIds.Event, "You have reconnected"))); } else { Program.Trace.TraceEvent(TraceEventType.Information, EventIds.Event, "You have reconnected"); } break; default: throw new ArgumentOutOfRangeException("e"); } }
internal void CallOnConnectionEvent(SocketConnectionEvent args) { try { Log.DebugFormat("CallOnConnectionEvent {0}", args); this.OnConnectionEvent(this, args); } catch (Exception e) { Log.Error("CallOnConnectionEvent Error", e); } }
internal void CallOnConnectionEvent(SocketConnectionEvent args) { try { Log.DebugFormat("CallOnConnectionEvent {0}", args); this.OnConnectionEvent(this, args); this.ConnectionChanged?.Invoke(this, new ConnectionChangedEventArgs { Event = args }); } catch (Exception e) { Log.Error("CallOnConnectionEvent Error", e); } }
public override void OnConnectionEvent(object sender, SocketConnectionEvent e) { Log.DebugFormat("OnConnectionEvent {0}",e); if (e == SocketConnectionEvent.Disconnected && !this.ForcedDisconnect) { Task.Factory.StartNew(this.DoReconnect); return; } if (e != SocketConnectionEvent.Disconnected) { this.RetryCount = 0; this.Reconnecting = false; this.ForcedDisconnect = false; } }
public override void OnConnectionEvent(object sender, SocketConnectionEvent e) { Log.DebugFormat("OnConnectionEvent {0}", e); if (e == SocketConnectionEvent.Disconnected && !this.ForcedDisconnect) { Task.Factory.StartNew(this.DoReconnect); return; } if (e != SocketConnectionEvent.Disconnected) { this.RetryCount = 0; this.Reconnecting = false; this.ForcedDisconnect = false; } }
public override void OnConnectionEvent(object sender, SocketConnectionEvent e) { Log.DebugFormat("ConnectionEvent {0} {1}", this.EndPoint, e); switch (e) { case SocketConnectionEvent.Disconnected: //var c = State.Instance.GetClient(this.Client); //if (c != null) // c.OnDisconnect(true); break; case SocketConnectionEvent.Connected: break; case SocketConnectionEvent.Reconnected: break; } }
public override void OnConnectionEvent(object sender, SocketConnectionEvent e) { Log.DebugFormat("OnConnectionEvent {0}", e); if (e == SocketConnectionEvent.Disconnected && !this.ForcedDisconnect) { if (_reportedDisconnect == false) { _reportedDisconnect = true; Log.ErrorFormat("Disconnect Event {0}", this.EndPoint); } Task.Factory.StartNew(this.DoReconnect); return; } if (e != SocketConnectionEvent.Disconnected) { this.RetryCount = 0; this.Reconnecting = false; this.ForcedDisconnect = false; this._reportedDisconnect = false; } }
public override void OnConnectionEvent(object sender, SocketConnectionEvent e) { Log.DebugFormat("OnConnectionEvent {0}", e); if (e == SocketConnectionEvent.Disconnected && !this.ForcedDisconnect) { if (_reportedDisconnect == false) { _reportedDisconnect = true; Log.ErrorFormat("Disconnect Event {0}",this.EndPoint); } Task.Factory.StartNew(this.DoReconnect); return; } if (e != SocketConnectionEvent.Disconnected) { this.RetryCount = 0; this.Reconnecting = false; this.ForcedDisconnect = false; this._reportedDisconnect = false; } }
public override void OnConnectionEvent(object sender, SocketConnectionEvent e) { base.OnConnectionEvent(sender, e); switch (e) { case SocketConnectionEvent.Disconnected: if (Program.GameEngine != null) Program.GameEngine.IsConnected = false; if (Program.Dispatcher != null) Program.Dispatcher.Invoke(new Action<string>(Program.TraceWarning), "You have been disconnected from server."); else Program.TraceWarning("You have been disconnected from server."); break; case SocketConnectionEvent.Connected: if (Program.GameEngine != null) Program.GameEngine.IsConnected = true; break; case SocketConnectionEvent.Reconnected: if (Program.GameEngine != null) { Program.GameEngine.IsConnected = true; Program.GameEngine.Resume(); } if (Program.Dispatcher != null) Program.Dispatcher.Invoke( new Action( () => Program.Trace.TraceEvent( TraceEventType.Information, EventIds.Event, "You have reconnected"))); else Program.Trace.TraceEvent(TraceEventType.Information, EventIds.Event, "You have reconnected"); break; default: throw new ArgumentOutOfRangeException("e"); } }
// 每帧检查处理消息 public void UpdateSocket() { // 向 Lua 发送缓存的socket链接状态 if (cacheConnectEvent != SocketConnectionEvent.None) { Debug.Log(cacheConnectEvent.ToString()); LuaUtils.PostLuaEvent(cacheConnectEvent.ToString(), null); cacheConnectEvent = SocketConnectionEvent.None; } // 检查是否有消息来了 if (null != _conn && _conn.State == SocketConnectionState.Connected) { List <SocketData> sockDatas = _conn.RecvSocketDataList(); if (sockDatas != null && sockDatas.Count > 0) { for (int i = 0; i < sockDatas.Count; ++i) { SocketData data = sockDatas [i]; ReceiveMsg msgData = new ReceiveMsg(); msgData.data = data; tobeHandledSocketData.Enqueue(msgData); } } } // 处理接收的消息 if (tobeHandledSocketData.Count > 0) { ReceiveMsg msgData = tobeHandledSocketData.Dequeue(); DealWithSocketData(msgData); } else { } }
public abstract void OnConnectionEvent(object sender, SocketConnectionEvent e);
private void OnConnectSuccessEvent(object sender, EventArgs e) { cacheConnectEvent = SocketConnectionEvent.ConnectSuccess; }
private void OnConnectLostEvent(object sender, EventArgs e) { cacheConnectEvent = SocketConnectionEvent.ConnectLost; }
public virtual void OnConnectionEvent(object sender, SocketConnectionEvent e) { }