Skip to content

Commit

Permalink
refactor: use Coroutine\go to Coroutine::create
Browse files Browse the repository at this point in the history
  • Loading branch information
cydrickn committed May 10, 2023
1 parent 0b53f21 commit 977b6ed
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/EventDispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class EventDispatcher

public function emit(string $eventName, ...$args): void
{
Coroutine\go(function () use ($eventName, $args) {
Coroutine::create(function () use ($eventName, $args) {
$events = $this->events[$eventName] ?? [];
if (empty($events)) {
return;
Expand Down
12 changes: 6 additions & 6 deletions src/Peer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Octamp\Client;

use Co\Http\Client as SwooleClient;
use Swoole\Coroutine\Http\Client as SwooleClient;
use Octamp\Client\Roles\AbstractRole;
use Octamp\Client\Roles\Callee;
use Octamp\Client\Roles\Caller;
Expand Down Expand Up @@ -78,17 +78,17 @@ public function open(): void
]);

$upgraded = $this->client->upgrade($this->path);
Coroutine\go(function () use ($upgraded) {
Coroutine::create(function () use ($upgraded) {
if ($upgraded) {
$this->startSession();
}
});

Coroutine\go(function () {
Coroutine::create(function () {
while ($this->client->connected) {
Coroutine::usleep(1);
$data = $this->client->recv();
Coroutine\go(function ($data) {
Coroutine::create(function ($data) {
$this->onMessage($data);
}, $data);
}
Expand Down Expand Up @@ -134,9 +134,9 @@ public function onMessage(Frame|bool $data): void
} elseif ($message instanceof WelcomeMessage) {
$this->processWelcome($message);
} elseif ($message instanceof AbortMessage) {

// TODO do abort message
} elseif ($message instanceof GoodbyeMessage) {

// TODO do goodby message
} else {
$this->processOther($this->session, $message);
}
Expand Down

0 comments on commit 977b6ed

Please sign in to comment.