void CLIServer::process() { CLIClientList *scan; for (scan = clients; scan; scan = scan->next) { uint8_t ctest = scan->client->testConnected(); if (ctest == CLIClient::CONNECTED) { if (_onConnect != NULL) { _onConnect(scan->client, 0, NULL); scan->client->printPrompt(); } } else if (ctest == CLIClient::DISCONNECTED) { if (_onDisconnect != NULL) { _onDisconnect(scan->client, 0, NULL); } } int rl = scan->client->readline(); if (rl > 0) { int rv = scan->client->parseCommand(); if (rv == -1) { scan->client->println("Unknown command"); } else { if (rv > 0) { scan->client->print("Error "); scan->client->println(rv); } } scan->client->printPrompt(); } else if (rl == 0) { scan->client->printPrompt(); } } }
void Connector::disconnected( void ) { if (_isConnected) { if (!_onDisconnect.empty()) { printf( "[Connector (%p)] Disconnected\n", this ); _onDisconnect(); } _isConnected = false; } }
void Connector::disconnected( void ) { // --Connector thread if (_isConnected) { printf( "[Connector (%p)] Disconnected\n", this ); // Send exit to all handlers BOOST_FOREACH( const HandlerElement &elem, _handlers ) { elem.second->notifyDisconnect(); } // Send global exit if (!_onDisconnect.empty()) { _onDisconnect(); } _isConnected = false; } }