Client is sending values in header while handshaking.
I want to receive those value in "onOpen" function of "Chat.php". (as in example)
Can you please tell me how to do that?
Thanks.
public function onOpen(ConnectionInterface $conn)
you can then access the request object by:
$conn->WebSocket->request
from there on you get access to the header, cookies, etc.
PHP Notice: Undefined property: Ratchet\Server\IoConnection::$WebSocket in C:\x
ampp\htdocs\NearPeople\socket\NearChat.php on line 18
Notice: Undefined property: Ratchet\Server\IoConnection::$WebSocket in C:\xampp\
htdocs\NearPeople\socket\NearChat.php on line 18
PHP Notice: Trying to get property of non-object in C:\xampp\htdocs\NearPeople\
socket\NearChat.php on line 18
Notice: Trying to get property of non-object in C:\xampp\htdocs\NearPeople\socke
t\NearChat.php on line 18
NULL
onOpen: 30onMessage: 30 || msg: GET / HTTP/1.1
Host: 192.168.9.156:8080
Connection: Upgrade
Upgrade: websocket
Sec-WebSocket-Version: 13
Sec-WebSocket-Key: 1a5YB/+iy69hqVakoQHqDQ==
PHP Notice: Trying to get property of non-object in C:\xampp\htdocs\NearPeople\
socket\Parser.php on line 13
Notice: Trying to get property of non-object in C:\xampp\htdocs\NearPeople\socke
t\Parser.php on line 13
Its giving me this error.
Can you post some source to assist in troubleshooting please?
I looked for a good time the solution, and I ended up finding. If it can help someone, I'll post it here:
public function onOpen(ConnectionInterface $conn) {
$headers = $conn->httpRequest->getHeaders();
// ...
}
I looked for a good time the solution, and I ended up finding. If it can help someone, I'll post it here:
public function onOpen(ConnectionInterface $conn) { $headers = $conn->httpRequest->getHeaders(); // ... }
its actually on "Ratchet\WebSocket\WsServer" line 112
as a guzzle object
Most helpful comment
I looked for a good time the solution, and I ended up finding. If it can help someone, I'll post it here: