Base amphp based stream interfaces for client and server websocket implementations
Base stream interfaces for client and server websocket implementations
This package can be installed as a Composer dependency.
composer require ekstazi/websocket-common
Three interfaces provided
Reads data from the stream. Return
Promise that resolves with a string when new data is available or
null if the stream has closed.
Send data as binary frames. This mode used by default.
Send data as utf-8 text frames.
Set default mode to write frames.
Get current default write mode.
Write data with specified write mode. By default value
Writer::getMode() used. Return promise that resolves with number of bytes written
Marks the stream as no longer writable. Optionally writes a final data chunk before. Note that this is not the same as forcefully closing the stream. This method waits for all pending writes to complete before closing the stream. Socket streams implementing this interface should only close the writable side of the stream.