[WebSocket] Refactor
Fixing bugs in hixieeeeeeee
This commit is contained in:
parent
c6a801f1ef
commit
f6fef1a390
@ -34,7 +34,10 @@ class Hixie76 implements VersionInterface {
|
|||||||
, 'Sec-WebSocket-Location' => 'ws://' . $request->getHeader('Host') . $request->getPath()
|
, 'Sec-WebSocket-Location' => 'ws://' . $request->getHeader('Host') . $request->getPath()
|
||||||
);
|
);
|
||||||
|
|
||||||
return new \Guzzle\Http\Message\Response('101', $headers, $body);
|
$response = new \Guzzle\Http\Message\Response('101', $headers, $body);
|
||||||
|
$response->setStatus('101', 'WebSocket Protocol Handshake');
|
||||||
|
|
||||||
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function newMessage() {
|
public function newMessage() {
|
||||||
|
@ -41,11 +41,7 @@ class RFC6455 implements VersionInterface {
|
|||||||
, 'Sec-WebSocket-Accept' => $this->sign($request->getHeader('Sec-WebSocket-Key'))
|
, 'Sec-WebSocket-Accept' => $this->sign($request->getHeader('Sec-WebSocket-Key'))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
return new \Guzzle\Http\Message\Response('101', $headers);
|
||||||
$response = new \Guzzle\Http\Message\Response(101, $headers);
|
|
||||||
return $response;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -79,23 +79,17 @@ class WebSocketComponent implements MessageComponentInterface {
|
|||||||
$response = $from->WebSocket->version->handshake($from->WebSocket->headers);
|
$response = $from->WebSocket->version->handshake($from->WebSocket->headers);
|
||||||
$from->WebSocket->handshake = true;
|
$from->WebSocket->handshake = true;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// This block is to be moved/changed later
|
// This block is to be moved/changed later
|
||||||
|
|
||||||
$agreed_protocols = array();
|
$agreed_protocols = array();
|
||||||
|
|
||||||
$requested_protocols = $from->WebSocket->headers->getTokenizedHeader('Sec-WebSocket-Protocol', ',');
|
$requested_protocols = $from->WebSocket->headers->getTokenizedHeader('Sec-WebSocket-Protocol', ',');
|
||||||
|
|
||||||
foreach ($this->accepted_subprotocols as $sub_protocol) {
|
foreach ($this->accepted_subprotocols as $sub_protocol) {
|
||||||
if (false !== $requested_protocols->hasValue($sub_protocol)) {
|
if (null !== $requested_protocols && false !== $requested_protocols->hasValue($sub_protocol)) {
|
||||||
$agreed_protocols[] = $sub_protocol;
|
$agreed_protocols[] = $sub_protocol;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($agreed_protocols) > 0) {
|
if (count($agreed_protocols) > 0) {
|
||||||
|
|
||||||
// $response['Sec-WebSocket-Protocol'] = implode(',', $agreed_protocols);
|
|
||||||
$response->setHeader('Sec-WebSocket-Protocol', implode(',', $agreed_protocols));
|
$response->setHeader('Sec-WebSocket-Protocol', implode(',', $agreed_protocols));
|
||||||
}
|
}
|
||||||
$header = (string)$response;
|
$header = (string)$response;
|
||||||
|
Loading…
Reference in New Issue
Block a user