Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add WebSocket client implementation #6

Merged
merged 24 commits into from
Oct 5, 2024
Merged

Add WebSocket client implementation #6

merged 24 commits into from
Oct 5, 2024

Conversation

thekid
Copy link
Member

@thekid thekid commented Oct 4, 2024

Example

use util\cmd\Console;
use websocket\WebSocket;

$remote= $argv[1] ?? 'wss://echo.websocket.events';
Console::writeLine('@@@ Connect ', $remote);
$s= new WebSocket($remote);
$s->connect();

Console::writeLine('<<< ', $s->receive());

$send= $argv[2] ?? 'Test!';
Console::writeLine('>>> ', $send);
$s->send($send);
Console::writeLine('<<< ', $s->receive());

Console::writeLine('>>> Ping');
$s->ping();
Console::writeLine('<<< ', $s->receive());

$s->close();

See https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API

@thekid thekid added the enhancement New feature or request label Oct 4, 2024
* @return void
*/
public function close($connection) { /* NOOP */ }
public function close($connection, $code, $reason) { /* NOOP */ }
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a BC break - all Listener implementations with a close() method need to be adapted!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thekid thekid merged commit 9bb66e9 into master Oct 5, 2024
20 checks passed
thekid added a commit to thekid/crews that referenced this pull request Oct 5, 2024
@thekid thekid deleted the feature/ws-client branch October 5, 2024 10:57
@thekid thekid mentioned this pull request Jan 12, 2025
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant