Skip to content

Commit

Permalink
hasRoute and isRoute methods were created
Browse files Browse the repository at this point in the history
  • Loading branch information
diloabininyeri committed Feb 4, 2024
1 parent fb7e4fe commit d5219fa
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docker_server.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ class Handler extends AbstractSocketClientHandler
#[Override]
public function run(): void
{

$this->hasRoute('/chat');//Is there any client connecting via /chat route?
$this->isRoute('/chat'); //Is the current client connected via the /chat route?
$this->sendTo()->everyone('hello wo');
}
}
Expand Down
19 changes: 19 additions & 0 deletions src/AbstractSocketClientHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,4 +180,23 @@ public function toStream(Socket $socket=null)
{
return socket_export_stream($socket ?: $this->client);
}
/***
* @param string $route
* @return bool
*/
protected function isRoute(string $route): bool
{
return $this->broadcast->hasJoin(
$this->createChannelNameByRoute($route),
$this->getClient()
);
}
/**
* @param string $route
* @return bool
*/
protected function hasRoute(string $route): bool
{
return $this->broadcast->hasChannel($this->createChannelNameByRoute($route));
}
}

0 comments on commit d5219fa

Please sign in to comment.