Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Websocket Client Laravel Package

amphp/websocket-client

Async WebSocket client for PHP built on Amp. Connect to ws/wss endpoints with fiber-friendly concurrency, consume realtime APIs, test WebSocket servers, and support custom handshakes, headers, heartbeats, and rate limits.

View on GitHub
Deep Wiki
Context7
v2.0.2
v2.0.1

What's Changed

New Contributors

Full Changelog: https://github.com/amphp/websocket-client/compare/v2.0.0...v2.0.1

v2.0.0

Stable release compatible with AMPHP v3 and fibers! 🎉

As with other libraries compatible with AMPHP v3, most cases of parameters or returns of Promise<ResolutionType> have been replaced with ResolutionType.

This release is compatible with amphp/http-client@^5 and amphp/websocket@^2. See the release notes of these libraries for further change notes.

Similar to v1, a Websocket connection is created using Amp\Websocket\Client\connect() or using an instance of WebsocketConnector, calling WebsocketConnector::connect(). The returned WebsocketConnection then is used to send and receive WebSocket messages.

  • Renamed most classes and interfaces to add Websocket as a prefix to avoid name collisions with similarly named classes in other packages which are frequently used together. For example, Connection is now WebsocketConnection.
  • Advanced handshake and connection parameters may be specified using a Rfc6455ConnectionFactory instance provided when constructing a Rfc6455Connector.
  • A global WebsocketConnector instance may be accessed and set via Amp\Websocket\Client\websocketConnector().
v2.0.0-beta.4
  • Compatibility with amphp/websocket@v2 and amphp/http-client@v5
v2.0.0-beta.3
  • Compatibility with amphp/http@v2
  • Added query-related methods to WebsocketHandshake
v2.0.0-beta.2
  • Updated for compatibility with amphp/socket@v2 and amphp/websocket@v2-beta.4
  • Altered Rfc6455ConnectionFactory constructor to use an instance of WebsocketParserFactory, moving some configuration options to Rfc6455ParserFactory
v2.0.0-beta.1

Initial release compatible with AMPHP v3.

As with other libraries compatible with AMPHP v3, most cases of parameters or returns of Promise<ResolutionType> have been replaced with ResolutionType.

  • Added Websocket as a prefix to several classes:
    • Connection renamed to WebsocketConnection
    • ConnectionFactory renamed to WebsocketConnectionFactory
    • Connector renamed to WebsocketConnector
    • ConnectionException renamed to WebsocketConnectException
    • Handshake renamed to WebsocketHandshake
  • Renamed connector function to websocketConnector
v1.0.1
  • Ignore /docs in .gitattributes to avoid broken symlink (#38)

Full Changelog: https://github.com/amphp/websocket-client/compare/v1.0.0...v1.0.1

v1.0.0

Changes since RC2

  • Removed header methods from Connection. Now the Response object is available with Connection::getResponse(), which provides access to the response headers and other response data.
  • Removed the connector() function, so there is no longer a global Connector object.
  • Fixed Handshake::withHeaders() to remove all prior set headers as expected.
  • Added ConnectContext parameter to connect() function.
  • ConnectionException now extends HttpException from amphp/http-client.

Upgrading from v0.2.x to v1.0

This library has been refactored to use the new amphp/websocket library containing components that can be shared between server and clients.

The simplest way to use this library is with the connect() function to initiate a WebSocket connection.

$connection = yield Amp\Websocket\Client\connect('ws://localhost:1337/broadcast');
yield $connection->send('Hello!');

/** [@var](https://github.com/var) Amp\Websocket\Message $message */
while ($message = yield $connection->receive()) {
    $payload = yield $message->buffer();
    // $payload now contains the entire message content
    yield $connection->send('Received message with length ' . strlen($payload));
}

Custom request headers and connections options can be set using the Handshake class and passing this object to connect() instead of a string URI. Connection behavior can be further customized by using an instance of Connector to establish a connection instead of the connect() function.

WebSocket clients are now represented by Connection, which extends the Client object from amphp/websocket. This object contains several methods for getting information about the client, fetching the headers returned in the server response, and sending/receiving messages.

v1.0.0-rc2
  • This library now uses HttpClient from amphp/http-client to send connection requests. As such, Rfc6455Connector requires an instance of HttpClient when constructed. The client may have various interceptors attached to modify behavior when connecting.
  • Updated to league/uri@^6, subsequently PHP 7.2+ is now required.
v1.0.0-rc1

This library has been refactored to use the new amphp/websocket library containing components that can be shared between server and clients.

Note: This is a pre-release, there might be breaking changes in the final stable version.

The simplest way to use this library is with the connect() function to initiate a WebSocket connection.

$connection = yield Amp\Websocket\Client\connect('ws://localhost:1337/broadcast');
yield $connection->send('Hello!');

/** [@var](https://github.com/var) Amp\Websocket\Message $message */
while ($message = yield $connection->receive()) {
    $payload = yield $message->buffer();
    // $payload now contains the entire message content
    yield $connection->send('Received message with length ' . strlen($payload));
}

Custom request headers and connections options can be set using the Handshake class and passing this object to connect() instead of a string URI. Connection behavior can be customized using the Connector interface or by extending the existing Rfc6455Connector class.

WebSocket clients are now represented by Connection, which extends the Client object from amphp/websocket. This object contains several methods for getting information about the client, fetching the headers returned in the server response, and sending/receiving messages.

v0.2.4
  • Fixed incorrect dependency that was only being loaded in dev mode.
  • Fixed port being added to host header if the port is non-standard (e.g., not 80/443).
v0.2.3
  • Fixed response header parsing (#16)
  • Fixed close code byte order and close reason (#15)
v0.2.2
  • Reject connections if RSV is not equals to 0.
  • Validate close reasons to be valid UTF-8 if UTF-8 validation has been requested.
  • Accept zero-length frames starting a message.
  • Deliver stored messages correctly if they're immediately followed by a close.
  • Reject continuations if there's no started message.
  • Disable streaming for frames. A single frame is now always buffered. A message can still be streamed via multiple frames.
v0.2.1
  • Fix handshake if no port is given in URL.
  • Correctly validate handshake response headers.
v0.2.0
  • Major API rewrite based on Amp v2.
v0.1.0
  • Release for Amp v1.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport