mezon-js 2.7.38 → 2.7.39

Sign up to get free protection for your applications and to get access to all the features.
@@ -4154,6 +4154,10 @@ var _DefaultSocket = class _DefaultSocket {
4154
4154
  n.content = n.content ? JSON.parse(n.content) : void 0;
4155
4155
  this.onnotification(n);
4156
4156
  });
4157
+ } else if (message.voice_started_event) {
4158
+ this.onvoicestarted(message.voice_started_event);
4159
+ } else if (message.voice_ended_event) {
4160
+ this.onvoiceended(message.voice_ended_event);
4157
4161
  } else if (message.voice_joined_event) {
4158
4162
  this.onvoicejoined(message.voice_joined_event);
4159
4163
  } else if (message.voice_leaved_event) {
@@ -4251,7 +4255,7 @@ var _DefaultSocket = class _DefaultSocket {
4251
4255
  };
4252
4256
  this.adapter.onError = (evt) => {
4253
4257
  reject(evt);
4254
- this.onerror(evt);
4258
+ this.adapter.close();
4255
4259
  };
4256
4260
  setTimeout(() => {
4257
4261
  reject("The socket timed out when trying to connect.");
@@ -4347,6 +4351,16 @@ var _DefaultSocket = class _DefaultSocket {
4347
4351
  console.log(statusPresence);
4348
4352
  }
4349
4353
  }
4354
+ onvoiceended(voice) {
4355
+ if (this.verbose && window && window.console) {
4356
+ console.log(voice);
4357
+ }
4358
+ }
4359
+ onvoicestarted(voice) {
4360
+ if (this.verbose && window && window.console) {
4361
+ console.log(voice);
4362
+ }
4363
+ }
4350
4364
  onvoicejoined(voiceParticipant) {
4351
4365
  if (this.verbose && window && window.console) {
4352
4366
  console.log(voiceParticipant);
@@ -4125,6 +4125,10 @@ var _DefaultSocket = class _DefaultSocket {
4125
4125
  n.content = n.content ? JSON.parse(n.content) : void 0;
4126
4126
  this.onnotification(n);
4127
4127
  });
4128
+ } else if (message.voice_started_event) {
4129
+ this.onvoicestarted(message.voice_started_event);
4130
+ } else if (message.voice_ended_event) {
4131
+ this.onvoiceended(message.voice_ended_event);
4128
4132
  } else if (message.voice_joined_event) {
4129
4133
  this.onvoicejoined(message.voice_joined_event);
4130
4134
  } else if (message.voice_leaved_event) {
@@ -4222,7 +4226,7 @@ var _DefaultSocket = class _DefaultSocket {
4222
4226
  };
4223
4227
  this.adapter.onError = (evt) => {
4224
4228
  reject(evt);
4225
- this.onerror(evt);
4229
+ this.adapter.close();
4226
4230
  };
4227
4231
  setTimeout(() => {
4228
4232
  reject("The socket timed out when trying to connect.");
@@ -4318,6 +4322,16 @@ var _DefaultSocket = class _DefaultSocket {
4318
4322
  console.log(statusPresence);
4319
4323
  }
4320
4324
  }
4325
+ onvoiceended(voice) {
4326
+ if (this.verbose && window && window.console) {
4327
+ console.log(voice);
4328
+ }
4329
+ }
4330
+ onvoicestarted(voice) {
4331
+ if (this.verbose && window && window.console) {
4332
+ console.log(voice);
4333
+ }
4334
+ }
4321
4335
  onvoicejoined(voiceParticipant) {
4322
4336
  if (this.verbose && window && window.console) {
4323
4337
  console.log(voiceParticipant);
package/dist/socket.d.ts CHANGED
@@ -238,6 +238,16 @@ export interface ChannelPresenceEvent {
238
238
  /** Presences of users who left the channel. */
239
239
  leaves: Presence[];
240
240
  }
241
+ export interface VoiceEndedEvent {
242
+ id: string;
243
+ clan_id: string;
244
+ voice_channel_id: string;
245
+ }
246
+ export interface VoiceStartedEvent {
247
+ id: string;
248
+ clan_id: string;
249
+ voice_channel_id: string;
250
+ }
241
251
  export interface VoiceLeavedEvent {
242
252
  id: string;
243
253
  clan_id: string;
@@ -602,6 +612,8 @@ export interface Socket {
602
612
  onmessagereaction: (messageReactionEvent: MessageReactionEvent) => void;
603
613
  /** Receive channel presence updates. */
604
614
  onchannelpresence: (channelPresence: ChannelPresenceEvent) => void;
615
+ onvoicestarted: (voice: VoiceStartedEvent) => void;
616
+ onvoiceended: (voice: VoiceEndedEvent) => void;
605
617
  onvoicejoined: (voiceParticipant: VoiceJoinedEvent) => void;
606
618
  onvoiceleaved: (voiceParticipant: VoiceLeavedEvent) => void;
607
619
  onchannelcreated: (channelCreated: ChannelCreatedEvent) => void;
@@ -652,6 +664,8 @@ export declare class DefaultSocket implements Socket {
652
664
  onpartymatchmakerticket(partyMatched: PartyMatchmakerTicket): void;
653
665
  onpartypresence(partyPresence: PartyPresenceEvent): void;
654
666
  onstatuspresence(statusPresence: StatusPresenceEvent): void;
667
+ onvoiceended(voice: VoiceEndedEvent): void;
668
+ onvoicestarted(voice: VoiceStartedEvent): void;
655
669
  onvoicejoined(voiceParticipant: VoiceJoinedEvent): void;
656
670
  onvoiceleaved(voiceParticipant: VoiceLeavedEvent): void;
657
671
  onchannelcreated(channelCreated: ChannelCreatedEvent): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mezon-js",
3
- "version": "2.7.38",
3
+ "version": "2.7.39",
4
4
  "scripts": {
5
5
  "build": "npx tsc && npx rollup -c --bundleConfigAsCjs && node build.mjs"
6
6
  },
package/socket.ts CHANGED
@@ -323,6 +323,24 @@ export interface ChannelPresenceEvent {
323
323
  leaves: Presence[];
324
324
  }
325
325
 
326
+ export interface VoiceEndedEvent {
327
+ // id voice
328
+ id: string;
329
+ // The unique identifier of the chat clan.
330
+ clan_id: string;
331
+ // voice channel name
332
+ voice_channel_id: string;
333
+ }
334
+
335
+ export interface VoiceStartedEvent {
336
+ // id voice
337
+ id: string;
338
+ // The unique identifier of the chat clan.
339
+ clan_id: string;
340
+ // voice channel name
341
+ voice_channel_id: string;
342
+ }
343
+
326
344
  export interface VoiceLeavedEvent {
327
345
  // event id
328
346
  id: string;
@@ -790,6 +808,12 @@ export interface Socket {
790
808
  /** Receive channel presence updates. */
791
809
  onchannelpresence: (channelPresence: ChannelPresenceEvent) => void;
792
810
 
811
+ // when someone start the voice room
812
+ onvoicestarted: (voice: VoiceStartedEvent) => void;
813
+
814
+ // when someone end the voice room
815
+ onvoiceended: (voice: VoiceEndedEvent) => void;
816
+
793
817
  // when someone join to voice room
794
818
  onvoicejoined: (voiceParticipant: VoiceJoinedEvent) => void;
795
819
 
@@ -877,6 +901,10 @@ export class DefaultSocket implements Socket {
877
901
  n.content = n.content ? JSON.parse(n.content) : undefined;
878
902
  this.onnotification(n);
879
903
  });
904
+ } else if (message.voice_started_event) {
905
+ this.onvoicestarted(message.voice_started_event)
906
+ } else if (message.voice_ended_event) {
907
+ this.onvoiceended(message.voice_ended_event)
880
908
  } else if (message.voice_joined_event) {
881
909
  this.onvoicejoined(message.voice_joined_event)
882
910
  } else if (message.voice_leaved_event) {
@@ -978,12 +1006,9 @@ export class DefaultSocket implements Socket {
978
1006
  }
979
1007
  this.adapter.onError = (evt: Event) => {
980
1008
  reject(evt);
981
- // TODO: do not close the adapter
982
- this.onerror(evt);
983
- //this.adapter.close();
1009
+ this.adapter.close();
984
1010
  }
985
1011
 
986
-
987
1012
  setTimeout(() => {
988
1013
  // if promise has resolved by now, the reject() is a no-op
989
1014
  reject("The socket timed out when trying to connect.");
@@ -1099,6 +1124,18 @@ export class DefaultSocket implements Socket {
1099
1124
  }
1100
1125
  }
1101
1126
 
1127
+ onvoiceended(voice: VoiceEndedEvent) {
1128
+ if (this.verbose && window && window.console) {
1129
+ console.log(voice);
1130
+ }
1131
+ }
1132
+
1133
+ onvoicestarted(voice: VoiceStartedEvent) {
1134
+ if (this.verbose && window && window.console) {
1135
+ console.log(voice);
1136
+ }
1137
+ }
1138
+
1102
1139
  onvoicejoined(voiceParticipant: VoiceJoinedEvent) {
1103
1140
  if (this.verbose && window && window.console) {
1104
1141
  console.log(voiceParticipant);