Ratchet websocket token 验证
in javascript:

new WebSocket('ws://server.com:8080?token=secret') 

in php:

public function onOpen(ConnectionInterface $conn)
{
    $querystring = $conn->httpRequest->getUri()->getQuery();
    parse_str($querystring,$queryarray);

    if(!isValid($queryarray['token'])) {
      return;
    }

    // store the new connection
    $this->clients->attach($conn);
    // echo "someone connected\n";
}

https://github.com/ratchetphp/Ratchet/issues/604

06-05 07:07