Forcefully closes this WebSocket. Immediately calls the close handler. No WebSocket close message is sent.
Gracefully closes this WebSocket. Immediately calls the close handler. A WebSocket close message is sent with code and shortMessage.
Optionalcode: numberOptionalshortMessage: RecognizedStringReturns the bytes buffered in backpressure. This is similar to the bufferedAmount property in the browser counterpart. Check backpressure example.
Returns the remote IP address. Note that the returned IP is binary, not text.
IPv4 is 4 byte long and can be converted to text by printing every byte as a digit between 0 and 255. IPv6 is 16 byte long and can be converted to text in similar ways, but you typically print digits in HEX.
See getRemoteAddressAsText() for a text version.
Returns the remote IP address as text. See RecognizedString.
Returns the remote port number.
Returns a list of topics this websocket is subscribed to.
Returns the UserData object.
Returns whether this websocket is subscribed to topic.
Sends a ping control message. Returns sendStatus similar to WebSocket.send (regarding backpressure). This helper function correlates to WebSocket::send(message, uWS::OpCode::PING, ...) in C++.
Optionalmessage: RecognizedStringPublish a message under topic. Backpressure is managed according to maxBackpressure, closeOnBackpressureLimit settings. Order is guaranteed since v20.
OptionalisBinary: booleanOptionalcompress: booleanSends a message. Returns 1 for success, 2 for dropped due to backpressure limit, and 0 for built up backpressure that will drain over time. You can check backpressure before or after sending by calling getBufferedAmount().
Make sure you properly understand the concept of backpressure. Check the backpressure example file.
OptionalisBinary: booleanOptionalcompress: booleanSends the first fragment of a fragmented message. Use for sending large messages in chunks. Returns 1 for success, 2 for dropped due to backpressure limit, and 0 for built up backpressure.
OptionalisBinary: booleanOptionalcompress: booleanSends a middle fragment of a fragmented message. Returns 1 for success, 2 for dropped due to backpressure limit, and 0 for built up backpressure.
Optionalcompress: booleanSends the last fragment of a fragmented message. Returns 1 for success, 2 for dropped due to backpressure limit, and 0 for built up backpressure.
Optionalcompress: booleanUnsubscribe from a topic. Returns true on success, if the WebSocket was subscribed.
A WebSocket connection that is valid from open to close event. Read more about this in the user manual.