Skip to content
This repository has been archived by the owner on Aug 25, 2022. It is now read-only.

Commit

Permalink
Addressing concerns
Browse files Browse the repository at this point in the history
  • Loading branch information
SeinopSys committed May 9, 2017
1 parent 584d708 commit f3b71e6
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/Engine/SocketIO/Version1X.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ protected function handshake()
throw new ServerConnectionFailureException;
}

$open_curly_at = strpos($result, '{');
$todecode = substr($result, $open_curly_at, strrpos($result, '}')-$open_curly_at+1);
$open_curly_at = strpos($result, '{');
$todecode = substr($result, $open_curly_at, strrpos($result, '}')-$open_curly_at+1);
$decoded = json_decode($todecode, true);

if (!in_array('websocket', $decoded['upgrades'])) {
Expand All @@ -186,18 +186,27 @@ protected function handshake()
$this->session = new Session($decoded['sid'], $decoded['pingInterval'], $decoded['pingTimeout'], $decoded['upgrades']);
}

/** Upgrades the transport to WebSocket */
/**
* Upgrades the transport to WebSocket
*
* FYI:
* Version "2" is used for the EIO param by socket.io v1
* Version "3" is used by socket.io v2
*/
protected function upgradeTransport()
{
$query = ['sid' => $this->session->id,
'EIO' => $this->options['version'],
'transport' => static::TRANSPORT_WEBSOCKET];

if ($this->options['version'] === 2)
$query['use_b64'] = $this->options['use_b64'];
if ($this->options['version'] === 2)
$query['use_b64'] = $this->options['use_b64'];

$url = sprintf('/%s/?%s', trim($this->url['path'], '/'), http_build_query($query));
$key = base64_encode(openssl_random_pseudo_bytes(16));
$hash = sha1(uniqid(mt_rand(), true), true);
if ($this->options['version'] !== 2)
$hash = substr($hash, 0, 16);
$key = base64_encode($hash);

$origin = '*';
$headers = isset($this->context['headers']) ? (array) $this->context['headers'] : [] ;
Expand Down

0 comments on commit f3b71e6

Please sign in to comment.