Skip to content

Commit

Permalink
chore: non-php code remover.
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcos Marcolin committed Aug 14, 2023
1 parent 0ecabe7 commit bdae191
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 33 deletions.
1 change: 0 additions & 1 deletion src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ public function writeToEngine($encodedPackets, $volatile = false)
if ($volatile && ! $this->conn->transport->writable) {
return;
}
// todo check
if (isset($encodedPackets['nsp'])) {
unset($encodedPackets['nsp']);
}
Expand Down
1 change: 0 additions & 1 deletion src/Engine/Socket.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ public function onUpgradePacket($packet)
}
}


public function upgradeCleanup()
{
$this->upgrading = false;
Expand Down
2 changes: 1 addition & 1 deletion src/Nsp.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public function clients($fn): Nsp
* @return Nsp {Socket} self
* @api public
*/
public function compress($compress)
public function compress($compress): Nsp
{
$this->flags['compress'] = $compress;
return $this;
Expand Down
36 changes: 6 additions & 30 deletions src/Parser/Decoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,36 +21,17 @@ public function __destruct()
/**
* @throws Exception
*/
public function add($obj)
public function add($obj): void
{
if (is_string($obj)) {
$packet = self::decodeString($obj);
if (Parser::BINARY_EVENT == $packet['type'] || Parser::BINARY_ACK == $packet['type']) {
// binary packet's json todo BinaryReconstructor
$this->reconstructor = new BinaryReconstructor(packet);

// no attachments, labeled binary but no binary data to follow
if ($this->reconstructor->reconPack->attachments === 0) {
$this->emit('decoded', $packet);
}
} else { // non-binary full packet
$this->emit('decoded', $packet);
}
} elseif (isBuf($obj) || ! empty($obj['base64'])) { // raw binary data
if (! $this->reconstructor) {
throw new Exception('got binary data when not reconstructing a packet');
} else {
$packet = $this->reconstructor->takeBinaryData($obj);
if ($packet) { // received final buffer
$this->reconstructor = null;
$this->emit('decoded', $packet);
}
}
} else {
throw new Exception('Unknown type: ' + obj);
$this->emit('decoded', $packet);
}
}

/**
* @throws Exception
*/
public function decodeString($str): array
{
$p = [];
Expand All @@ -67,7 +48,7 @@ public function decodeString($str): array
$buf = '';
while ($str[++$i] != '-') {
$buf .= $str[$i];
if ($i == strlen(str)) {
if ($i == strlen($str)) {
break;
}
}
Expand Down Expand Up @@ -116,7 +97,6 @@ public function decodeString($str): array

// look up json data
if (isset($str[++$i])) {
// todo try
$p['data'] = json_decode(substr($str, $i), true);
}

Expand All @@ -130,8 +110,4 @@ public static function error(): array
'data' => 'parser error'
];
}

public function destroy()
{
}
}

0 comments on commit bdae191

Please sign in to comment.