function socketChanged($socket) { while (socket_recv($socket, $buf, 1024, 0) >= 1) { $received_text = WebSocketServer::unmask($buf); //unmask data $this->doGetMessage($received_text); return AbstractSocketServer::$INCOMING_DATA; } $buf = @socket_read($socket, 1024, PHP_NORMAL_READ); if ($buf === false) { // check disconnected client // remove client for $clients array $found_socket = array_search($socket, $this->clients); unset($this->clients[$found_socket]); $this->doLoseConnect($socket); return AbstractSocketServer::$LOSE_CONNECT; } }