private function parseUrl($uri)
{
$result = new stdClass();
$p = parse_url($uri);
if ($p) {
switch (strtolower($p['scheme'])) {
case 'ws':
$result->host = $p['host'];
$result->port = isset($p['port']) ? $p['port'] : 80;
$result->type = SWOOLE_SOCK_TCP;
break;
case 'wss':
$result->host = $p['host'];
$result->port = isset($p['port']) ? $p['port'] : 443;
$result->type = SWOOLE_SOCK_TCP | SWOOLE_SSL;
break;
default:
throw new Exception("Can't support this scheme: {$p['scheme']}");
}
} else {
throw new Exception("Can't parse this uri: {$uri}");
}
return $result;
}