// either the player disconnected from the server or quit the game private void OnConnectionLost(ConnectionLostEvent e) { // just pass the info through if (ConnectionLostEvent != null) { ConnectionLostEvent(new Dictionary <string, object>()); } }
public void Disconnect() { if (!Connected) { return; } Connected = false; ConnectionLostEvent?.Invoke(this); Dispose(); }
private static void CheckConnection(object sender, EventArgs e) { try { proxy.IsActive(); } catch (Exception) { ConnectionLostEvent?.Invoke(null, null); StopConnectionTimer(); } }
void HandleOnBleDidDisconnectEvent(string errorMessage) { if (errorMessage != null) { Debug.Log("Error during disconnection: " + errorMessage); return; } searchBleDevicesButton.SetActive(true); disconnectButton.SetActive(false); meteoStationFeed.SetActive(false); infoMessage.GetComponent <Text>().text = "Device did disconnect."; ConnectionLostEvent?.Invoke(); }
private void ReciveMessages() { while (true) { try { var builder = new StringBuilder(); var data = new byte[GlobalConfig.GlobalConfig.Size]; UserMessage receivedObject; do { var bytes = Stream.Read(data, 0, data.Length); receivedObject = JsonSerializer.Deserialize <UserMessage>(Encoding.UTF8.GetString(data, 0, bytes)); builder.Append(receivedObject); }while (Stream.DataAvailable); MessageReceivedEvent?.Invoke(receivedObject); var message = builder.ToString(); Console.WriteLine(message); } catch (JsonException ex) { Console.WriteLine(ex.Message); break; } catch (Exception ex) when(ex is SocketException || ex is IOException) { Console.WriteLine($"Error: {ex.Message} = {ex.GetType()} Подключение прервано!"); RunEventDelegatesAsync(ConnectionLostEvent?.GetInvocationList()); break; } } }
private void OnConnectionLost(ConnectionLostEvent e) { Console.WriteLine("connection lost"); }
public void ConnectionLost() { Application.Current.Dispatcher.BeginInvoke(new Action(() => { ConnectionLostEvent?.Invoke(); })); }