예제 #1
0
                 echo "[DEBUG] policy server: client connected...\n";
             }
         } else {
             if (DEBUG) {
                 echo "[DEBUG] client connected...\n";
             }
         }
         $sockets[] = $new;
         $clients[] = false;
         if (DEBUG) {
             echo "[DEBUG] about to dispatch open event\n";
         }
         module::dispatch_event('open', false, count($sockets) - 1, array());
     }
 } else {
     response::set_current_sock($sock, $s);
     //if the socket is not a websocket
     if ($clients[$sock] != 'websocket') {
         $str = '';
         do {
             $buf = socket_read($s, 2048);
             if ($buf === false) {
                 echo "[ERROR] socket_read() failed: reason: " . socket_strerror(socket_last_error($s)) . "\n";
                 module::dispatch_event('close', false, $sock, array());
                 // close socket
                 socket_close($s);
                 unset($sockets[$sock]);
                 unset($clients[$sock]);
                 //array_splice($sockets, $sock, 1);
                 //array_splice($clients, $sock, 1);
             }