public void OnConnectorDisconnectHandler(object sender, object disconnectionState) { IConnector connector = sender as IConnector; if (connector == null) { return; } connector.DisconnectEvent -= OnConnectorDisconnectHandler; TeamPainterTCPClient client = null; lock (_cSync) { long clientID; _clientConnectionAssociation.TryGetAndRemove(connector.UniqueID, out clientID); _clients.TryGetAndRemove(clientID, out client); } if (client != null) { client.Connector.DisconnectEvent -= OnConnectorDisconnectHandler; client.Connector.ReceiveAction -= OnReceveDataHandler; client.Connector.ReceiveComAction -= OnReceiveCommandHandler; } NetLogger.Log(connector.UniqueID + " is disconnected"); DisconnectEvent?.Invoke(client, disconnectionState); }
public void Stop() { cts?.Cancel(); cycleTask?.GetAwaiter().GetResult(); StateConnect = false; DisconnectEvent?.Invoke(this, new EventArgs()); }
public void Dispose() { try { if (QuikLua != null && QuikLua.Service.IsConnected().Result) { QuikLua.Service.QuikService.Stop(); } } catch (Exception error) { SendLogMessage(error.ToString(), LogMessageType.Error); } if (QuikLua != null) { QuikLua.Events.OnConnected -= EventsOnOnConnected; QuikLua.Events.OnDisconnected -= EventsOnOnDisconnected; QuikLua.Events.OnConnectedToQuik -= EventsOnOnConnectedToQuik; QuikLua.Events.OnDisconnectedFromQuik -= EventsOnOnDisconnectedFromQuik; QuikLua.Events.OnTrade -= EventsOnOnTrade; QuikLua.Events.OnOrder -= EventsOnOnOrder; QuikLua.Events.OnQuote -= EventsOnOnQuote; QuikLua.Events.OnFuturesClientHolding -= EventsOnOnFuturesClientHolding; QuikLua.Events.OnFuturesLimitChange -= EventsOnOnFuturesLimitChange; } ServerStatus = ServerConnectStatus.Disconnect; DisconnectEvent?.Invoke(); subscribedBook = new List <string>(); QuikLua = null; }
public override void Disconnect() { if (DisconnectEvent != null) { DisconnectEvent.Invoke(); } base.Disconnect(); }
private void OnDisconnect(int deviceId) { Debug.Log($"OnDisconnect({deviceId})"); PlayerManager.Instance.DisconnectPlayer(deviceId); DisconnectEvent?.Invoke(this, new DisconnectEventArgs(deviceId)); }
public void OnDisconnectEvent(int hostId, int connectionId, NetworkError error) { DisconnectEvent?.Invoke(connectionId); print("|Disconnect event: " + "/n|HostId: " + hostId + "/n|ConnectionId : " + connectionId + "/n|Error: " + error.ToString()); }
public void Disconnect() { if (currentSocket.Connected) { log.NormalLog(string.Format("Disconnect information,ID:{0} , IPAdderss:{1}", ID, CurrentSocket.RemoteEndPoint)); currentSocket.Disconnect(true); DisconnectEvent?.Invoke(this); } isUsed = false; }
public void Close() { if (StateConnect) { Socket.Close(); Socket.Dispose(); StateConnect = false; requestHandler.LostCustomerConnection(); DisconnectEvent?.Invoke(this, new EventArgs()); } }
private void _disconnect() { if (Connected) { Debug.Log("Disconnected"); Connected = false; Client.Close(); NetStream = null; Disconnected.Invoke(Error); } }
public void Disconnect() { var s = ((AsyncUserToken)socketArg.UserToken).AcceptSocket; if (s.Connected) { s.Shutdown(SocketShutdown.Both); } log.NormalLog(string.Format("Disconnect information,ID:{0} , IPAdderss:{1}", ID, s.RemoteEndPoint)); s.Close(); DisconnectEvent?.Invoke(this); }
/// <summary> /// PLC心跳事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void _hbTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { _hbTimer.Stop(); int result = 1; // 不为0的正整数 lock (syncObj) { result = _s7Client.DBRead(10, 0, 1, _hbbuf); // PLC CPU可达, 更新心跳时间 } if (result == 0) { _hbNow = DateTime.Now; } if (_hbNow.AddSeconds(3) < DateTime.Now) //连接时长超过10s表示心跳信号中断 { if (_isConnected) // 第一次连接中断 { DisconnectEvent?.Invoke(this, null); // 更新包括Mainform _isConnected = false; return; } //else // 试着重新连接 //{ // if (_reConnect) // 自动进行5s的重连 // { // Stopwatch sw = new Stopwatch(); // sw.Start(); // while (true) // { // if (sw.Elapsed > TimeSpan.FromSeconds(5)) // { // _reConnect = false; // break; // } // int connOk = _s7Client.Connect(); // // 连接成功 // if (connOk == 0) // { // ReconnectEvent?.Invoke(this, null); // _isConnected = true; // } // } // sw.Stop(); // } //} } if (_isConnected) { _hbTimer.Start(); } }
/// <summary> /// Disconnect from the current server. /// </summary> public void Disconnect() { UpdateManager.StopUdpUpdates(); _udpNetClient.Disconnect(); IsConnected = false; // Clear all client addon packet handlers, because their IDs become invalid _packetManager.ClearClientAddonPacketHandlers(); // Invoke callback if it exists DisconnectEvent?.Invoke(); }
public void Disconnect() { if (ConnectState) { cts.Cancel(); if (taskCycleRead != null) { taskCycleRead.Wait(); } commands.Disconnect(); ConnectState = false; } DisconnectEvent?.Invoke(this, new EventArgs()); }
public bool DisConnect() { if (IsConnect) { _socket?.Close(); } _socketArg?.Dispose(); _socket?.Dispose(); _socket = null; _socketArg = null; _isConnect = false; _subSocketArgFlag = false; DisconnectEvent?.Invoke(this); return(true); }
private void OnDisconnectEventHandler(object sender, object disconnectState) { _TCP.DisconnectEvent -= OnDisconnectEventHandler; _TCP.ReceiveAction -= OnReceveDataHandler; _TCP.ReceiveComAction -= OnReceiveCommandHandler; _clientID = 0; _isActive = false; string s = "Disconnected "; if (disconnectState != null) { s += disconnectState.ToString(); } NetLogger.Log(s); DisconnectEvent?.Invoke(_TCP, disconnectState); _TCP = null; }
public void Stop() { try { if (_eventSourceClient != null) { _eventSourceClient.Disconnect(); _log.Debug($"SSE Handler stoped..."); } } catch (Exception ex) { _log.Debug($"SSE Handler Stop: {ex.Message}"); DisconnectEvent?.Invoke(this, new FeedbackEventArgs(false)); } }
private void ReceiveMessage(object socket) { Socket receiveSocket = (Socket)socket; while (listening) { try { int length = receiveSocket.Receive(buffer); if (length == 0) { DisconnectEvent?.Invoke(this, receiveSocket); break; } else { int lastIndexOfEnd = 0; for (int i = 0; i < length; i++) { if (buffer[i] == '\0') { if (i == 0) { continue; } MessageSorter(buffer, lastIndexOfEnd, i - 1 - lastIndexOfEnd, receiveSocket); lastIndexOfEnd = i + 1; } } } } catch (Exception e) { if (e.GetType() == typeof(SocketException)) { SocketException se = (SocketException)e; if (se.ErrorCode == 10054) { DisconnectEvent?.Invoke(this, receiveSocket); Thread.CurrentThread.Abort(); } } ShowMessage(e.Message + "\n" + e.StackTrace + "\n"); } } ShowMessage("接收" + receiveSocket.RemoteEndPoint.ToString() + "的线程已结束\n"); }
/// <summary> /// Disconnect the local client from the server. /// </summary> /// <param name="sendDisconnect">Whether to tell the server we are disconnecting.</param> public void Disconnect(bool sendDisconnect = true) { if (_netClient.IsConnected) { if (sendDisconnect) { // First send the server that we are disconnecting Logger.Get().Info(this, "Sending PlayerDisconnect packet"); _netClient.UpdateManager.SetPlayerDisconnect(); } // Then actually disconnect _netClient.Disconnect(); // Let the player manager know we disconnected _playerManager.OnDisconnect(); // Clear the player data dictionary _playerData.Clear(); _uiManager.OnClientDisconnect(); _addonManager.ClearNetworkedAddonIds(); // Check whether the game is in the pause menu and reset timescale to 0 in that case if (UIManager.instance.uiState.Equals(UIState.PAUSED)) { PauseManager.SetTimeScale(0); } try { DisconnectEvent?.Invoke(); } catch (Exception e) { Logger.Get().Warn(this, $"Exception thrown while invoking Disconnect event, {e.GetType()}, {e.Message}, {e.StackTrace}"); } } else { Logger.Get().Warn(this, "Could not disconnect client, it was not connected"); } }
private async Task StartCycle(CancellationToken cancellationToken) { try { await Task.Run(() => CycleMeasureCurrent(cancellationToken)); } catch (OperationCanceledException) { } catch (Exception e) { if (Exception == null) { Exception = e; ExceptionEvent?.Invoke(this, new EventArgs()); } } finally { transport.Dispose(); DisconnectEvent?.Invoke(this, new EventArgs()); } }
public Client() { Host = "192.168.1.105"; Port = 7366; m_transport = new TransportTcp(); m_transport.SocketMessageEvent += (sender, args) => { try { m_heartbeatService.ResetTime(); var envelope = Envelope.Parser.ParseFrom(args.Data); var collationId = envelope.CollationId; KeyValuePair <Action <Envelope>, Action <Error> > pair; if (m_collationIds.TryGetValue(collationId, out pair)) { pair.Key(envelope); m_collationIds.Remove(collationId); } else { Action <Envelope> action; if (m_notifications.TryGetValue(envelope.PayloadCase, out action)) { action(envelope); } } } catch (Exception) { Cleanup(); } }; m_transport.SocketClosedEvent += (sender, args) => { m_collationIds.Clear(); DisconnectEvent?.Invoke(); }; }
public void OnConnectorDisconnectHandler(object sender, object disconnectionState) { IConnector connector = sender as IConnector; if (connector == null) { return; } connector.DisconnectEvent -= OnConnectorDisconnectHandler; connector.ReceiveAction -= OnReceveDataHandler; connector.ReceiveComAction -= OnReceiveCommandHandler; lock (_cSync) { _connectors.Remove(connector.UniqueID); } NetLogger.Log(connector.UniqueID + " disconneted. " + (disconnectionState == null ? "" : disconnectionState.ToString())); DisconnectEvent?.Invoke(connector, disconnectionState); }
private void ServerThread(object data) { bool isAnonymous = (bool)data; ServerPipe serverPipe = new ServerPipe("Test", p => p.StartStringReaderAsync()); serverPipe.DataReceived += (sndr, args) => { DataRecievedHandler(serverPipe, args, isAnonymous); }; serverPipe.Connected += (sndr, args) => { Profile selectedObject = _profile; if (!_serverPipes.ContainsKey(selectedObject.Id)) { serverPipe.Id = selectedObject.Id; _serverPipes.Add(selectedObject.Id, serverPipe); } }; serverPipe.PipeClosed += (sndr, args) => { DisconnectEvent.Invoke(this, serverPipe.Id); }; }
private void OnDisconnectEvent() { DisconnectEvent?.Invoke(this, System.EventArgs.Empty); }
private void EventsOnOnDisconnected() { ServerStatus = ServerConnectStatus.Disconnect; DisconnectEvent?.Invoke(); }
public void OnDisconnectEvent() { DisconnectEvent?.Invoke(this, "Another user disconnected your call"); }
void Client_Disconnected() { ServerStatus = ServerConnectStatus.Disconnect; DisconnectEvent?.Invoke(); }
void HandleMessage(string msg, dynamic args, Request request) { LogDebug("(in) " + request.type + " " + msg); LogVerbose("... " + JsonConvert.SerializeObject(request)); args = args ?? new { }; try { switch (msg) { case "initialize": var cap = new Capabilities(); InitializeEvent?.Invoke(request, cap); Send(request, cap); Initialized(); break; case "configurationDone": ConfigurationDoneEvent?.Invoke(request); break; case "launch": LaunchEvent?.Invoke(request, JsonConvert.SerializeObject(args)); break; case "attach": AttachEvent?.Invoke(request, JsonConvert.SerializeObject(args)); break; case "disconnect": DisconnectEvent?.Invoke(request); break; case "next": StepOverEvent?.Invoke(request); break; case "continue": ContinueEvent?.Invoke(request); break; case "stepIn": StepInEvent?.Invoke(request); break; case "stepOut": StepOutEvent?.Invoke(request); break; case "pause": PauseEvent?.Invoke(request); break; case "threads": GetThreadsEvent?.Invoke(request); break; case "scopes": GetScopesEvent?.Invoke(request, (int)args.frameId); break; case "stackTrace": GetStackTraceEvent?.Invoke(request); break; case "variables": _tempVariables.Clear(); GetVariablesEvent?.Invoke(request, (int)args.variablesReference, _tempVariables); Send(request, new VariablesResponseBody(_tempVariables)); break; case "setVariable": var variable = new Variable((string)args.name, (string)args.value, "", (int)args.variablesReference); SetVariableEvent?.Invoke( request, variable ); Send( request, new SetVariableResponseBody(variable.value, variable.variablesReference) ); break; case "loadedSources": GetLoadedSourcesEvent?.Invoke(request); break; case "source": GetSourceEvent?.Invoke(request); break; case "evaluate": string resultEval = ""; EvaluateEvent?.Invoke( request, (int)args.frameId, (string)args.context, (string)args.expression, (bool)(args.format?.hex ?? false), ref resultEval ); Send( request, new EvaluateResponseBody( resultEval ) ); break; case "completions": GetCompletionsEvent?.Invoke( request, (int)args.frameId, (int)args.line, (int)args.column, (string )args.text ); break; case "setBreakpoints": SetBreakpointsEvent?.Invoke(request); break; // case "runInTerminal": // OnRunInTerminal?.Invoke( pRequest ); // break; // case "setFunctionBreakpoints": // SetFunctionBreakpoints( pResponse, pArgs ); // break; // case "setExceptionBreakpoints": // SetExceptionBreakpoints( pResponse, pArgs ); // break; default: CustomRequestEvent?.Invoke(request); if (!request.responded) { Log( Logging.Severity.Error, string.Format("Request not handled: '{0}' [{1}]", msg, Convert.Encode(request.arguments.ToString())) ); } break; } } catch (Exception e) { Log( Logging.Severity.Error, $"Error during request '{Convert.Encode( request.arguments.ToString() )}' [{msg}] (exception: {e.Message})\n{e}" ); Send(new Response(request, errorMsg: e.Message)); } }
protected void OnDisconnectEvent() { ServerStatus = ServerConnectStatus.Disconnect; DisconnectEvent?.Invoke(); }
private void OnDisconnectEvent(EventArgs e) { DisconnectEvent?.Invoke(this, e); }
private void ConnectState_DisconnectEvent(SaeaConnectState obj) { DisconnectEvent?.Invoke(obj); }