Skip to content

Commit

Permalink
Request response browser streaming (#579)
Browse files Browse the repository at this point in the history
Co-authored-by: Bret Ambrose <[email protected]>
  • Loading branch information
bretambrose and Bret Ambrose authored Dec 3, 2024
1 parent 2ea576e commit 71c2eef
Show file tree
Hide file tree
Showing 37 changed files with 11,461 additions and 77 deletions.
2 changes: 1 addition & 1 deletion .builder/actions/crt_size_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def run(self, env):
# Maximum package size (for current platform) in bytes
# NOTE: if you increase this, you might also need to increase the
# limit in continuous-delivery/pack.sh
max_size = 8_000_000
max_size = 8_250_000
# size of current folder
folder_size = 0
# total size in bytes
Expand Down
2 changes: 2 additions & 0 deletions lib/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import * as http from './browser/http';
import * as crypto from './browser/crypto';
import * as iot from './browser/iot';
import * as auth from './browser/auth';
import * as mqtt_request_response from './browser/mqtt_request_response';
import { ICrtError, CrtError } from './browser/error';

export {
Expand All @@ -31,6 +32,7 @@ export {
io,
iot,
mqtt,
mqtt_request_response,
mqtt5,
platform,
promise,
Expand Down
10 changes: 8 additions & 2 deletions lib/browser/io.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
* @mergeTarget
*/

export { TlsVersion, SocketType, SocketDomain } from "../common/io";
import { SocketType, SocketDomain } from "../common/io";
import { setLogLevel, LogLevel, SocketType, SocketDomain } from "../common/io";
// Do not re-export the logging functions in common; they are package-private
export { setLogLevel, LogLevel, TlsVersion, SocketType, SocketDomain } from "../common/io";


/**
* @return false, as ALPN is not configurable from the browser
Expand Down Expand Up @@ -112,3 +114,7 @@ export class SocketOptions {
public keep_alive_max_failed_probes = 0) {
}
}

export function enable_logging(level: LogLevel) {
setLogLevel(level);
}
9 changes: 9 additions & 0 deletions lib/browser/mqtt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,15 @@ export class MqttClientConnection extends BufferedEventEmitter {
});
}

/**
* Queries whether the client is currently connected
*
* @returns whether the client is currently connected
*/
is_connected() : boolean {
return this.currentState == MqttBrowserClientState.Connected;
}

private on_connect = (connack: mqtt.IConnackPacket) => {
this.on_online(connack.sessionPresent);
}
Expand Down
9 changes: 9 additions & 0 deletions lib/browser/mqtt5.ts
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,15 @@ export class Mqtt5Client extends BufferedEventEmitter implements mqtt5.IMqtt5Cli
});
}

/**
* Queries whether the client is currently connected
*
* @returns whether the client is currently connected
*/
isConnected() : boolean {
return this.lifecycleEventState == Mqtt5ClientLifecycleEventState.Connected;
}

/**
* Event emitted when the client encounters a disruptive error condition. Not currently used.
*
Expand Down
661 changes: 661 additions & 0 deletions lib/browser/mqtt_request_response.spec.ts

Large diffs are not rendered by default.

Loading

0 comments on commit 71c2eef

Please sign in to comment.