Skip to content

Commit

Permalink
Expose remote address in getInfo (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
kelunik authored and trowski committed Feb 6, 2019
1 parent c61d46f commit 0e752e6
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Internal/Rfc6455Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class Rfc6455Client
public $compressionContext;

// getInfo() properties
public $remoteAddress;
public $connectedAt;
public $closedAt = 0;
public $closeCode;
Expand Down
2 changes: 2 additions & 0 deletions src/Internal/Rfc6455Gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ public function reapClient(
$client->capacity = $this->maxBytesPerMinute;
$client->connectedAt = $this->now;
$client->id = (int) $socket->getResource();
$client->remoteAddress = $socket->getRemoteAddress();
$client->socket = $socket;
$client->compressionContext = $compressionContext;

Expand Down Expand Up @@ -925,6 +926,7 @@ public function getInfo(int $clientId): array
$client = $this->clients[$clientId];

return [
'remote_address' => $client->remoteAddress,
'bytes_read' => $client->bytesRead,
'bytes_sent' => $client->bytesSent,
'frames_read' => $client->framesRead,
Expand Down
1 change: 1 addition & 0 deletions src/Websocket.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ final public function close(int $clientId, int $code = Code::NORMAL_CLOSE, strin
* @param int $clientId
*
* @return array [
* 'remote_address' => string|null,
* 'bytes_read' => int,
* 'bytes_sent' => int,
* 'frames_read' => int,
Expand Down

0 comments on commit 0e752e6

Please sign in to comment.