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
";
}

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

本站无任何商业行为
个人在线分享 » Ratchet websocket token 验证
E-->