diff --git a/index.d.ts b/index.d.ts index 46b64d0a..4723ec2a 100644 --- a/index.d.ts +++ b/index.d.ts @@ -73,13 +73,7 @@ export interface WebSocket { /** Sends a ping control message. Returns true on success in similar ways as WebSocket.send does (regarding backpressure). This helper function correlates to WebSocket::send(message, uWS::OpCode::PING, ...) in C++. */ ping(message?: RecognizedString) : boolean; - /** Subscribe to a topic in MQTT syntax. - * - * MQTT syntax includes things like "root/child/+/grandchild" where "+" is a - * wildcard and "root/#" where "#" is a terminating wildcard. - * - * Read more about MQTT. - */ + /** Subscribe to a topic. */ subscribe(topic: RecognizedString) : boolean; /** Unsubscribe from a topic. Returns true on success, if the WebSocket was subscribed. */ @@ -91,15 +85,8 @@ export interface WebSocket { /** Returns a list of topics this websocket is subscribed to. */ getTopics() : string[]; - /** Publish a message to a topic in MQTT syntax. You cannot publish using wildcards, only fully specified topics. Just like with MQTT. - * - * "parent/child" kind of tree is allowed, but not "parent/#" kind of wildcard publishing. - * - * The pub/sub system does not guarantee order between what you manually send using WebSocket.send - * and what you publish using WebSocket.publish. WebSocket messages are perfectly atomic, but the order in which they appear can get scrambled if you mix the two sending functions on the same socket. - * This shouldn't matter in most applications. Order is guaranteed relative to other calls to WebSocket.publish. - * - * Also keep in mind that backpressure will be automatically managed with pub/sub, meaning some outgoing messages may be dropped if backpressure is greater than specified maxBackpressure. + /** Publish a message under topic. Backpressure is managed according to maxBackpressure, closeOnBackpressureLimit settings. + * Order is guaranteed since v20. */ publish(topic: RecognizedString, message: RecognizedString, isBinary?: boolean, compress?: boolean) : boolean; @@ -143,8 +130,8 @@ export interface HttpResponse { * See writeStatus and corking. */ writeHeader(key: RecognizedString, value: RecognizedString) : HttpResponse; - /** Enters or continues chunked encoding mode. Writes part of the response. End with zero length write. */ - write(chunk: RecognizedString) : HttpResponse; + /** Enters or continues chunked encoding mode. Writes part of the response. End with zero length write. Returns true if no backpressure was added. */ + write(chunk: RecognizedString) : boolean; /** Ends this response by copying the contents of body. */ end(body?: RecognizedString, closeConnection?: boolean) : HttpResponse; /** Ends this response, or tries to, by streaming appropriately sized chunks of body. Use in conjunction with onWritable. Returns tuple [ok, hasResponded].*/ @@ -237,6 +224,8 @@ export interface WebSocketBehavior { compression?: CompressOptions; /** Maximum length of allowed backpressure per socket when publishing or sending messages. Slow receivers with too high backpressure will be skipped until they catch up or timeout. Defaults to 1024 * 1024. */ maxBackpressure?: number; + /** Whether or not we should automatically send pings to uphold a stable connection given whatever idleTimeout. */ + sendPingsAutomatically?: number; /** Upgrade handler used to intercept HTTP upgrade requests and potentially upgrade to WebSocket. * See UpgradeAsync and UpgradeSync example files. */ @@ -338,12 +327,14 @@ export interface MultipartField { /** Takes a POSTed body and contentType, and returns an array of parts if the request is a multipart request */ export function getParts(body: RecognizedString, contentType: RecognizedString): MultipartField[] | undefined; -/** WebSocket compression options */ +/** WebSocket compression options. Combine any compressor with any decompressor using bitwise OR. */ export type CompressOptions = number; /** No compression (always a good idea if you operate using an efficient binary protocol) */ export var DISABLED: CompressOptions; -/** Zero memory overhead compression (recommended for pub/sub where same message is sent to many receivers) */ +/** Zero memory overhead compression. */ export var SHARED_COMPRESSOR: CompressOptions; +/** Zero memory overhead decompression. */ +export var SHARED_DECOMPRESSOR: CompressOptions; /** Sliding dedicated compress window, requires 3KB of memory per socket */ export var DEDICATED_COMPRESSOR_3KB: CompressOptions; /** Sliding dedicated compress window, requires 4KB of memory per socket */ @@ -360,3 +351,19 @@ export var DEDICATED_COMPRESSOR_64KB: CompressOptions; export var DEDICATED_COMPRESSOR_128KB: CompressOptions; /** Sliding dedicated compress window, requires 256KB of memory per socket */ export var DEDICATED_COMPRESSOR_256KB: CompressOptions; +/** Sliding dedicated decompress window, requires 32KB of memory per socket (plus about 23KB) */ +export var DEDICATED_DECOMPRESSOR_32KB: CompressOptions; +/** Sliding dedicated decompress window, requires 16KB of memory per socket (plus about 23KB) */ +export var DEDICATED_DECOMPRESSOR_16KB: CompressOptions; +/** Sliding dedicated decompress window, requires 8KB of memory per socket (plus about 23KB) */ +export var DEDICATED_DECOMPRESSOR_8KB: CompressOptions; +/** Sliding dedicated decompress window, requires 4KB of memory per socket (plus about 23KB) */ +export var DEDICATED_DECOMPRESSOR_4KB: CompressOptions; +/** Sliding dedicated decompress window, requires 2KB of memory per socket (plus about 23KB) */ +export var DEDICATED_DECOMPRESSOR_2KB: CompressOptions; +/** Sliding dedicated decompress window, requires 1KB of memory per socket (plus about 23KB) */ +export var DEDICATED_DECOMPRESSOR_1KB: CompressOptions; +/** Sliding dedicated decompress window, requires 512B of memory per socket (plus about 23KB) */ +export var DEDICATED_DECOMPRESSOR_512B: CompressOptions; +/** Sliding dedicated decompress window, requires 32KB of memory per socket (plus about 23KB) */ +export var DEDICATED_DECOMPRESSOR: CompressOptions; \ No newline at end of file diff --git a/source_commit b/source_commit index bd95872a..011017ad 100644 --- a/source_commit +++ b/source_commit @@ -1 +1 @@ -c70d2e6d2d923183885e991c6cb4189419b521a5 +2f829d1b361c0f468edfc3ee94eb97d32f81229e