ServerWebSocketSendStatus

TServerWebSocketSendStatus
Bun

Symbol

ServerWebSocketSendStatus

type ServerWebSocketSendStatus = number

A status that represents the outcome of a sent message.

  • if 0, the message was dropped.
  • if -1, there is backpressure of messages.
  • if >0, it represents the number of bytes sent.
const status = ws.send("Hello!");
if (status === 0) {
  console.log("Message was dropped");
} else if (status === -1) {
  console.log("Backpressure was applied");
} else {
  console.log(`Success! Sent ${status} bytes`);
}