PHP WebSocket – How send message to specified client? -
sending messages clients looks this:
function send_message($msg) { global $clients; foreach($clients $changed_socket) { socket_write($changed_socket, $msg, strlen($msg)); } return true; }
how can send message specified client, example client #2? $clients array looks this:
array ( [0] [1] [2] [3] )
instead of running foreach loop send messages every client, send 1 want.
function send_message($msg) { global $clients; socket_write($clients[2], $msg, strlen($msg)); return true; }
Comments
Post a Comment