Skip to content

Commit

Permalink
fix: cometics
Browse files Browse the repository at this point in the history
  • Loading branch information
chipslays committed Feb 16, 2023
1 parent 863a423 commit 7bba08d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
3 changes: 1 addition & 2 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@

class Client
{
use Rawable;
use Payloadable;
use Rawable, Payloadable;

public AsyncTcpConnection $connection;

Expand Down
21 changes: 11 additions & 10 deletions src/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@

class Server
{
use Rawable;
use Mappable;
use Singleton;
use Payloadable;
use Rawable, Mappable, Singleton, Payloadable;

protected Worker $worker;

Expand Down Expand Up @@ -104,17 +101,19 @@ public function create(string $address, array $context = []): self
/**
* Emitted when a socket connection is successfully established.
*
* Fire before `onWebsocketConnected`.
*
* @param callable|null $handler
* @return self
*/
public function onWebsocketConnected(?callable $handler = null): self
public function onConnected(?callable $handler = null): self
{
if (!$handler) {
return $this;
}

$this->getWorker()->onWebSocketConnect = function (TcpConnection $connection, string $header) use ($handler) {
call_user_func_array($handler, [new Connection($connection), $header]);
$this->getWorker()->onConnect = function (TcpConnection $connection) use ($handler) {
call_user_func_array($handler, [new Connection($connection)]);
};

return $this;
Expand All @@ -123,17 +122,19 @@ public function onWebsocketConnected(?callable $handler = null): self
/**
* Emitted when a socket connection is successfully established.
*
* Fire after `onConnected`.
*
* @param callable|null $handler
* @return self
*/
public function onConnected(?callable $handler = null): self
public function onWebsocketConnected(?callable $handler = null): self
{
if (!$handler) {
return $this;
}

$this->getWorker()->onConnect = function (TcpConnection $connection) use ($handler) {
call_user_func_array($handler, [new Connection($connection)]);
$this->getWorker()->onWebSocketConnect = function (TcpConnection $connection, string $header) use ($handler) {
call_user_func_array($handler, [new Connection($connection), $header]);
};

return $this;
Expand Down

0 comments on commit 7bba08d

Please sign in to comment.