@serve.zone/platformclient 3.0.0 → 4.0.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.
@@ -21,7 +21,7 @@ export class SzLetterConnector {
21
21
  }
22
22
 
23
23
  const typedRequest =
24
- this.platformClientRef.typedsocket.createTypedRequest<plugins.servezoneInterfaces.platform.letter.IReq_SendLetter>(
24
+ this.platformClientRef.requireTypedSocket().createTypedRequest<plugins.servezoneInterfaces.platform.letter.IReq_SendLetter>(
25
25
  'sendLetter'
26
26
  );
27
27
  const response = await typedRequest.fire(optionsArg);
@@ -20,7 +20,7 @@ export class SzPushNotificationConnector {
20
20
  }
21
21
 
22
22
  const typedRequest =
23
- this.platformClientRef.typedsocket.createTypedRequest<plugins.servezoneInterfaces.platform.pushnotification.IReq_SendPushNotification>(
23
+ this.platformClientRef.requireTypedSocket().createTypedRequest<plugins.servezoneInterfaces.platform.pushnotification.IReq_SendPushNotification>(
24
24
  'sendPushNotification'
25
25
  );
26
26
  const response = await typedRequest.fire(optionsArg);
@@ -22,7 +22,7 @@ export class SzSmsConnector {
22
22
  return;
23
23
  }
24
24
 
25
- const typedrequest = this.platformClientRef.typedsocket.createTypedRequest<plugins.servezoneInterfaces.platform.sms.IReq_SendSms>(
25
+ const typedrequest = this.platformClientRef.requireTypedSocket().createTypedRequest<plugins.servezoneInterfaces.platform.sms.IReq_SendSms>(
26
26
  'sendSms'
27
27
  );
28
28
  const response = await typedrequest.fire(messageArg);
@@ -40,7 +40,7 @@ export class SzSmsConnector {
40
40
 
41
41
 
42
42
  const typedrequest =
43
- this.platformClientRef.typedsocket.createTypedRequest<plugins.servezoneInterfaces.platform.sms.IReq_SendVerificationCode>(
43
+ this.platformClientRef.requireTypedSocket().createTypedRequest<plugins.servezoneInterfaces.platform.sms.IReq_SendVerificationCode>(
44
44
  'sendVerificationCode'
45
45
  );
46
46
  const response = await typedrequest.fire(recipientArg);
@@ -182,12 +182,8 @@ export class SzWebPushConnector {
182
182
  return;
183
183
  }
184
184
  if (socketPromise) {
185
- try {
186
- const pendingSocket = await socketPromise;
187
- await pendingSocket.stop();
188
- } catch {
189
- // A failed or aborted connection leaves no socket to close.
190
- }
185
+ const pendingSocket = await socketPromise.catch(() => undefined);
186
+ await pendingSocket?.stop();
191
187
  }
192
188
  }
193
189
 
@@ -268,6 +264,7 @@ export class SzWebPushConnector {
268
264
  }
269
265
 
270
266
  private async getWebPushTypedSocket(urlArg: string): Promise<plugins.typedsocket.TypedSocket> {
267
+ this.platformClientRef.assertRunning();
271
268
  const normalizedUrl = this.normalizeTypedSocketUrl(urlArg);
272
269
  if (this.webPushTypedSocket && this.webPushTypedSocketUrl === normalizedUrl) {
273
270
  return this.webPushTypedSocket;
@@ -278,11 +275,12 @@ export class SzWebPushConnector {
278
275
  if (this.webPushTypedSocket || this.webPushTypedSocketPromise) {
279
276
  await this.stop();
280
277
  }
278
+ this.platformClientRef.assertRunning();
281
279
  this.webPushTypedSocketUrl = normalizedUrl;
282
280
  const abortController = new AbortController();
283
281
  this.webPushTypedSocketAbortController = abortController;
284
282
  const socketPromise = plugins.typedsocket.TypedSocket.createClient(
285
- this.platformClientRef.typedrouter,
283
+ new plugins.typedrequest.TypedRouter(),
286
284
  normalizedUrl,
287
285
  { autoReconnect: true, abortSignal: abortController.signal },
288
286
  );
File without changes