I have me a socket created in PHP that I am connecting to in flash/as3. Its working 99%, but…
$bytes = socket_recv($socket, $buffer, 2048, 0);
if ($bytes == 0) {
//User disconnects
$index = array_search($socket, $read_sockets);
$tehEC = socket_last_error();
$CID = $read_sockets[$index];
$DNAME = $DB->db->query("SELECT * FROM chat_online WHERE connectid='$CID'");
$BROW = $DB->db->fetch_array($DNAME);
$BNAME = $BROW['user_name'];
$DB->db->query("DELETE FROM chat_online WHERE connectid='$CID'");
echo "dc " . $tehEC . "\n";
send_Message($allclients, $socket, $BNAME . ": /disconnected " . $BNAME); <-- WILL NOT SEND
unset($read_sockets[$index]);
send_Message($allclients, $socket, $BNAME . ": /disconnected " . $BNAME); <-- WILL NOT SEND
socket_close($socket);
}
So I have been able to get an event to fire when a user disconnects and all, but that line not sending makes my life really hard 🙁 any help please? I need it to send that to the other clients so I can remove the users. So again, how can I get the socket server to send a message to all still online clients so they know to remove the disconnected user from the list.
Actually the problem was I needed to add chr(0) to the end of the string to get it to send. Thank you for the responses though.