void WebSocketServer::listen() { // First check existing connections: for( byte x=0; x < m_maxConnections; x++ ) { if( !m_connections[x] ) continue; WebSocket *s = m_connections[x]; if( !s->isConnected() ) { m_connectionCount--; delete s; m_connections[x] = NULL; continue; } s->listen(); } EthernetClient cli = m_server.available(); if( !cli ) return; // Find a slot: for( byte x=0; x < m_maxConnections; x++ ) { if( m_connections[x] ) continue; WebSocket *s = new WebSocket(this, cli); m_connections[x] = s; m_connectionCount++; #ifdef DEBUG Serial.println(F("Websocket client connected.")); #endif return; } // No room! #ifdef DEBUG Serial.println(F("Cannot accept new websocket client, maxConnections reached!")); #endif cli.stop(); }