Method
WebSocket::send
Send a text message; nothing happens once the connection is closed.
Description#
public WebSocket::send(
string $text
): voidMay be called from any coroutine; messages from different coroutines never interleave.
Waits while the client reads slowly, and gives the client up (closing the connection)
after WebSocket::WRITE_TIMEOUT seconds.
Parameters#
- $text string
- The message, which must be UTF-8
Errors / Exceptions#
| Exception | When |
|---|---|
ValueError | When $text is not valid UTF-8 |
Examples#
$ws->send(json_encode(['type' => 'welcome']));See also#
WebSocket::sendBinarySend a binary message; nothing happens once the connection is closed.