private async void TCPConnection_ConnectionStateChanged(AbstractConnection2 connection, ConnectionStateChangedEventArgs args) { switch (args.newState) { case ConnectionState.CONNECTED: // TCP connection established start reading: TCP_CONNECTION.startReaderTask(); // Send initial stream header: await softRestartAsync(); break; case ConnectionState.ERROR: if (args.param is ConnectionError cError) { lastConnectionError = cError; } if (args.oldState == ConnectionState.CONNECTED) { switch (state) { case ConnectionState.CONNECTING: case ConnectionState.CONNECTED: await onConnectionErrorAsync(); break; case ConnectionState.DISCONNECTING: setState(ConnectionState.DISCONNECTED); break; } } else { // Unable to connect to server: connectionErrorCount = 3; await internalDisconnectAsync(); setState(ConnectionState.ERROR, args.param); } break; case ConnectionState.DISCONNECTED when holdConnection: await reconnectAsync(false); break; } }
//--------------------------------------------------------Events:---------------------------------------------------------------------\\ #region --Events-- private void Connection_ConnectionStateChanged(AbstractConnection2 connection, Events.ConnectionStateChangedEventArgs args) { if (args.newState == ConnectionState.CONNECTED) { requestDisoInfo(); } else if (args.newState == ConnectionState.DISCONNECTED) { // Stop message processors: if (discoMessageResponseHelper != null) { discoMessageResponseHelper.Dispose(); discoMessageResponseHelper = null; } if (carbonsMessageResponseHelper != null) { carbonsMessageResponseHelper.Dispose(); carbonsMessageResponseHelper = null; } } }
private async void CONNECTION_ConnectionStateChanged(AbstractConnection2 connection, Events.ConnectionStateChangedEventArgs arg) { switch (arg.newState) { case ConnectionState.CONNECTED: if (!CONNECTION.account.checkOmemoKeys()) { setState(OmemoHelperState.ERROR); Logger.Error("[OMEMO HELPER](" + CONNECTION.account.getBareJid() + ") Failed - no keys!"); } else if (STATE == OmemoHelperState.DISABLED) { await requestDeviceListAsync(); } break; case ConnectionState.DISCONNECTED: case ConnectionState.ERROR: reset(); break; } }