[WebSocket] Only select one sub-protocol, fixes #103
This commit is contained in:
parent
9a50835637
commit
5676161277
@ -199,19 +199,15 @@ class WsServer implements HttpServerInterface {
|
|||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function getSubProtocolString(\Traversable $requested = null) {
|
protected function getSubProtocolString(\Traversable $requested = null) {
|
||||||
if (null === $requested) {
|
if (null !== $requested) {
|
||||||
return '';
|
foreach ($requested as $sub) {
|
||||||
}
|
if ($this->isSubProtocolSupported($sub)) {
|
||||||
|
return $sub;
|
||||||
$result = array();
|
}
|
||||||
|
|
||||||
foreach ($requested as $sub) {
|
|
||||||
if ($this->isSubProtocolSupported($sub)) {
|
|
||||||
$result[] = $sub;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return implode(',', $result);
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -27,10 +27,11 @@ class WsServerTest extends \PHPUnit_Framework_TestCase {
|
|||||||
|
|
||||||
public function protocolProvider() {
|
public function protocolProvider() {
|
||||||
return array(
|
return array(
|
||||||
array('hello,world', array('hello', 'world'), array('hello', 'world'))
|
array('hello', array('hello', 'world'), array('hello', 'world'))
|
||||||
, array('', array('hello', 'world'), array('wamp'))
|
, array('', array('hello', 'world'), array('wamp'))
|
||||||
, array('', array(), null)
|
, array('', array(), null)
|
||||||
, array('wamp', array('hello', 'wamp', 'world'), array('herp', 'derp', 'wamp'))
|
, array('wamp', array('hello', 'wamp', 'world'), array('herp', 'derp', 'wamp'))
|
||||||
|
, array('wamp', array('wamp'), array('wamp'))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user