Example #1
0
         } else {
             $log->lwrite("main:: Incorrect Password for user: "******" IP: " . $sock->sockadmin[$ckey]['ip'], 1);
             // So what are we going to do when we receive a wrong password
         }
     }
     // If we do NOT have a cookie, we need to use a login form
     // cause only if we connect from remote, we'll need to login first
     // This is async, we only write the request, the answer will arrive in time
     //
     $logmsg = array('tcnt' => $tcnt . "", 'action' => 'login', 'type' => 'raw', 'address' => $sock->clientIP);
     if (false === ($message = json_encode($logmsg))) {
         $log->lwrite("ERROR main:: json_encode failed: <" . $logmsg['tcnt'] . ", " . $logmsg['action'] . ">");
     }
     $log->lwrite("Json encoded login: "******"ERROR main:: failed writing login message on socket");
     }
     $log->lwrite("main:: writing message on socket OK", 2);
 } else {
     $log->lwrite("main:: client is trusted: " . $sock->clientIP, 2);
     // Compose ACK reply for the client that sent us this message.
     // At this moment we use the raw message format in message ...
     $reply = array('tcnt' => $tcnt . "", 'type' => 'raw', 'action' => "ack", 'message' => "OK");
     if (false === ($message = json_encode($reply))) {
         $log->lwrite("ERROR main:: json_encode reply: <" . $reply['tcnt'] . "," . $reply['action'] . ">", 1);
     }
     // First check whether this is necessary. Some raw sockets are not websockets encoded
     // XXX $answer = $sock->s_encode($tmp);			// Websocket encode
     $log->lwrite("main:: json reply : <" . $message . "> len: " . strlen($message), 2);
     // Send the reply