The problem:
Ok, now the user send data through normal HTTP request to the server, PHP did the process needed and fetch the result from the database, now I want to send these data back to a user throughout WS instead of HTTP.
Used technology:
PHP & Ratchet
JS
Code:
Normal websocket ran by command
$server = IoServer::factory(
new HttpServer(
new WsServer(
new Receiver()
)
),
env('CHAT_PORT',8080)
);
$server->run();
and the receiver has a property called $userAuthSocketMapper
which map between the Authentication key of the user (the http side) and the resourceId (the ws side).
What am thinking of:
If i only can get the Receiver
instance which ran by Ratchet, I can easily access its resourceId property and its send method to send the data to the user i want. but how to get that instance when user send http request instead of ws request !