@larksuiteoapi/node-sdk 1.57.0 → 1.58.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/es/index.js CHANGED
@@ -85571,6 +85571,35 @@ class WSClient {
85571
85571
  getReconnectInfo() {
85572
85572
  return this.reconnectInfo;
85573
85573
  }
85574
+ /**
85575
+ * close connection
85576
+ * @param params close params
85577
+ * @param params.force whether force close (use terminate instead of close)
85578
+ */
85579
+ close(params = {}) {
85580
+ const { force = false } = params;
85581
+ if (this.pingInterval) {
85582
+ clearTimeout(this.pingInterval);
85583
+ this.pingInterval = undefined;
85584
+ }
85585
+ if (this.reconnectInterval) {
85586
+ clearTimeout(this.reconnectInterval);
85587
+ this.reconnectInterval = undefined;
85588
+ }
85589
+ this.isConnecting = false;
85590
+ const wsInstance = this.wsConfig.getWSInstance();
85591
+ if (wsInstance) {
85592
+ wsInstance.removeAllListeners();
85593
+ if (force) {
85594
+ wsInstance.terminate();
85595
+ }
85596
+ else {
85597
+ wsInstance.close();
85598
+ }
85599
+ this.wsConfig.setWSInstance(null);
85600
+ }
85601
+ this.logger.info('[ws]', `ws client closed manually${force ? ' (force)' : ''}`);
85602
+ }
85574
85603
  start(params) {
85575
85604
  return __awaiter(this, void 0, void 0, function* () {
85576
85605
  this.logger.info('[ws]', `receive events or callbacks through persistent connection only available in self-build & Feishu app, Configured in:
package/lib/index.js CHANGED
@@ -85586,6 +85586,35 @@ class WSClient {
85586
85586
  getReconnectInfo() {
85587
85587
  return this.reconnectInfo;
85588
85588
  }
85589
+ /**
85590
+ * close connection
85591
+ * @param params close params
85592
+ * @param params.force whether force close (use terminate instead of close)
85593
+ */
85594
+ close(params = {}) {
85595
+ const { force = false } = params;
85596
+ if (this.pingInterval) {
85597
+ clearTimeout(this.pingInterval);
85598
+ this.pingInterval = undefined;
85599
+ }
85600
+ if (this.reconnectInterval) {
85601
+ clearTimeout(this.reconnectInterval);
85602
+ this.reconnectInterval = undefined;
85603
+ }
85604
+ this.isConnecting = false;
85605
+ const wsInstance = this.wsConfig.getWSInstance();
85606
+ if (wsInstance) {
85607
+ wsInstance.removeAllListeners();
85608
+ if (force) {
85609
+ wsInstance.terminate();
85610
+ }
85611
+ else {
85612
+ wsInstance.close();
85613
+ }
85614
+ this.wsConfig.setWSInstance(null);
85615
+ }
85616
+ this.logger.info('[ws]', `ws client closed manually${force ? ' (force)' : ''}`);
85617
+ }
85589
85618
  start(params) {
85590
85619
  return __awaiter(this, void 0, void 0, function* () {
85591
85620
  this.logger.info('[ws]', `receive events or callbacks through persistent connection only available in self-build & Feishu app, Configured in:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@larksuiteoapi/node-sdk",
3
- "version": "1.57.0",
3
+ "version": "1.58.0",
4
4
  "description": "larksuite open sdk for nodejs",
5
5
  "keywords": [
6
6
  "feishu",
package/types/index.d.ts CHANGED
@@ -293072,6 +293072,14 @@ declare class WSClient {
293072
293072
  lastConnectTime: number;
293073
293073
  nextConnectTime: number;
293074
293074
  };
293075
+ /**
293076
+ * close connection
293077
+ * @param params close params
293078
+ * @param params.force whether force close (use terminate instead of close)
293079
+ */
293080
+ close(params?: {
293081
+ force?: boolean;
293082
+ }): void;
293075
293083
  start(params: {
293076
293084
  eventDispatcher: EventDispatcher;
293077
293085
  }): Promise<void>;