mezon-js 2.9.58 → 2.9.61
Sign up to get free protection for your applications and to get access to all the features.
- package/api.gen.ts +310 -0
- package/client.ts +109 -0
- package/dist/api.gen.d.ts +68 -0
- package/dist/client.d.ts +7 -1
- package/dist/mezon-js.cjs.js +252 -8
- package/dist/mezon-js.esm.mjs +252 -8
- package/dist/socket.d.ts +16 -6
- package/package.json +1 -1
- package/socket.ts +47 -20
package/dist/socket.d.ts
CHANGED
@@ -556,7 +556,7 @@ export interface StreamingEndedEvent {
|
|
556
556
|
/** channel id */
|
557
557
|
channel_id: string;
|
558
558
|
}
|
559
|
-
export interface
|
559
|
+
export interface PermissionSet {
|
560
560
|
/** Role ID */
|
561
561
|
role_id: string;
|
562
562
|
/** User ID */
|
@@ -568,10 +568,16 @@ export interface SetPermissionChannelEvent {
|
|
568
568
|
/** */
|
569
569
|
caller: string;
|
570
570
|
}
|
571
|
-
export interface
|
571
|
+
export interface PermissionChangedEvent {
|
572
572
|
user_id: string;
|
573
573
|
channel_id: string;
|
574
574
|
}
|
575
|
+
export interface TokenSentEvent {
|
576
|
+
sender_id: string;
|
577
|
+
sender_name: string;
|
578
|
+
receiver_id: string;
|
579
|
+
amount: number;
|
580
|
+
}
|
575
581
|
/** A socket connection to Mezon server. */
|
576
582
|
export interface Socket {
|
577
583
|
/** Connection is Open */
|
@@ -614,6 +620,8 @@ export interface Socket {
|
|
614
620
|
writeVoiceJoined(id: string, clanId: string, clanName: string, voiceChannelId: string, voiceChannelLabel: string, participant: string, lastScreenshot: string): Promise<VoiceJoinedEvent>;
|
615
621
|
/** send voice leaved */
|
616
622
|
writeVoiceLeaved(id: string, clanId: string, voiceChannelId: string, voiceUserId: string): Promise<VoiceLeavedEvent>;
|
623
|
+
/** send token */
|
624
|
+
sendToken(receiver_id: string, amount: number): Promise<TokenSentEvent>;
|
617
625
|
/** Handle disconnect events received from the socket. */
|
618
626
|
ondisconnect: (evt: Event) => void;
|
619
627
|
/** Handle error events received from the socket. */
|
@@ -680,8 +688,8 @@ export interface Socket {
|
|
680
688
|
onstreamingchannelended: (streaming_ended_event: StreamingEndedEvent) => void;
|
681
689
|
onstreamingchanneljoined: (streaming_joined_event: StreamingJoinedEvent) => void;
|
682
690
|
onstreamingchannelleaved: (streaming_leaved_event: StreamingLeavedEvent) => void;
|
683
|
-
|
684
|
-
|
691
|
+
onpermissionset: (permission_set_event: PermissionSet) => void;
|
692
|
+
onpermissionchanged: (permission_changed_event: PermissionChangedEvent) => void;
|
685
693
|
}
|
686
694
|
/** Reports an error received from a socket message. */
|
687
695
|
export interface SocketError {
|
@@ -752,8 +760,9 @@ export declare class DefaultSocket implements Socket {
|
|
752
760
|
onstreamingchannelended(streaming_ended_event: StreamingEndedEvent): void;
|
753
761
|
onstreamingchanneljoined(streaming_joined_event: StreamingJoinedEvent): void;
|
754
762
|
onstreamingchannelleaved(streaming_leaved_event: StreamingLeavedEvent): void;
|
755
|
-
|
756
|
-
|
763
|
+
onpermissionset(permission_set_event: PermissionSet): void;
|
764
|
+
onpermissionchanged(permission_changed_event: PermissionChangedEvent): void;
|
765
|
+
ontokensent(tokenSentEvent: TokenSentEvent): void;
|
757
766
|
send(message: ChannelJoin | ChannelLeave | ChannelMessageSend | ChannelMessageUpdate | CustomStatusEvent | ChannelMessageRemove | MessageTypingEvent | LastSeenMessageEvent | Rpc | StatusFollow | StatusUnfollow | StatusUpdate | Ping, sendTimeout?: number): Promise<any>;
|
758
767
|
followUsers(userIds: string[]): Promise<Status>;
|
759
768
|
joinClanChat(clan_id: string): Promise<ClanJoin>;
|
@@ -773,6 +782,7 @@ export declare class DefaultSocket implements Socket {
|
|
773
782
|
writeVoiceLeaved(id: string, clanId: string, voiceChannelId: string, voiceUserId: string): Promise<VoiceLeavedEvent>;
|
774
783
|
writeCustomStatus(clan_id: string, status: string): Promise<CustomStatusEvent>;
|
775
784
|
checkDuplicateName(name: string, condition_id: string, type: number): Promise<CheckNameExistedEvent>;
|
785
|
+
sendToken(receiver_id: string, amount: number): Promise<TokenSentEvent>;
|
776
786
|
private pingPong;
|
777
787
|
}
|
778
788
|
export {};
|
package/package.json
CHANGED
package/socket.ts
CHANGED
@@ -781,7 +781,7 @@ export interface StreamingEndedEvent {
|
|
781
781
|
channel_id: string;
|
782
782
|
}
|
783
783
|
|
784
|
-
export interface
|
784
|
+
export interface PermissionSet {
|
785
785
|
/** Role ID */
|
786
786
|
role_id: string;
|
787
787
|
/** User ID */
|
@@ -794,11 +794,22 @@ export interface SetPermissionChannelEvent {
|
|
794
794
|
caller: string;
|
795
795
|
}
|
796
796
|
|
797
|
-
export interface
|
797
|
+
export interface PermissionChangedEvent{
|
798
798
|
user_id: string;
|
799
799
|
channel_id: string;
|
800
800
|
}
|
801
801
|
|
802
|
+
export interface TokenSentEvent {
|
803
|
+
// sender id
|
804
|
+
sender_id: string;
|
805
|
+
// sender name
|
806
|
+
sender_name: string;
|
807
|
+
// receiver
|
808
|
+
receiver_id: string;
|
809
|
+
// amount of token
|
810
|
+
amount: number;
|
811
|
+
}
|
812
|
+
|
802
813
|
/** A socket connection to Mezon server. */
|
803
814
|
export interface Socket {
|
804
815
|
/** Connection is Open */
|
@@ -861,6 +872,9 @@ export interface Socket {
|
|
861
872
|
/** send voice leaved */
|
862
873
|
writeVoiceLeaved(id: string, clanId: string, voiceChannelId: string, voiceUserId: string) : Promise<VoiceLeavedEvent>;
|
863
874
|
|
875
|
+
/** send token */
|
876
|
+
sendToken(receiver_id: string, amount: number) : Promise<TokenSentEvent>;
|
877
|
+
|
864
878
|
/** Handle disconnect events received from the socket. */
|
865
879
|
ondisconnect: (evt: Event) => void;
|
866
880
|
|
@@ -987,9 +1001,9 @@ export interface Socket {
|
|
987
1001
|
|
988
1002
|
onstreamingchannelleaved: (streaming_leaved_event: StreamingLeavedEvent) => void;
|
989
1003
|
|
990
|
-
|
1004
|
+
onpermissionset: (permission_set_event: PermissionSet) => void;
|
991
1005
|
|
992
|
-
|
1006
|
+
onpermissionchanged: (permission_changed_event: PermissionChangedEvent) => void;
|
993
1007
|
}
|
994
1008
|
|
995
1009
|
/** Reports an error received from a socket message. */
|
@@ -1189,10 +1203,12 @@ export class DefaultSocket implements Socket {
|
|
1189
1203
|
this.onstreamingchanneljoined(<StreamingJoinedEvent>message.streaming_joined_event);
|
1190
1204
|
} else if(message.streaming_leaved_event){
|
1191
1205
|
this.onstreamingchannelleaved(<StreamingLeavedEvent>message.streaming_leaved_event);
|
1192
|
-
} else if(message.
|
1193
|
-
this.
|
1194
|
-
} else if(message.
|
1195
|
-
this.
|
1206
|
+
} else if(message.permission_set_event){
|
1207
|
+
this.onpermissionset(<PermissionSet>message.permission_set_event);
|
1208
|
+
} else if(message.permission_changed_event){
|
1209
|
+
this.onpermissionchanged(<PermissionChangedEvent>message.permission_changed_event);
|
1210
|
+
} else if (message.token_sent_event) {
|
1211
|
+
this.ontokensent(<TokenSentEvent>message.token_sent_event);
|
1196
1212
|
} else {
|
1197
1213
|
if (this.verbose && window && window.console) {
|
1198
1214
|
console.log("Unrecognized message received: %o", message);
|
@@ -1501,15 +1517,21 @@ export class DefaultSocket implements Socket {
|
|
1501
1517
|
}
|
1502
1518
|
}
|
1503
1519
|
|
1504
|
-
|
1520
|
+
onpermissionset(permission_set_event: PermissionSet){
|
1521
|
+
if (this.verbose && window && window.console) {
|
1522
|
+
console.log(permission_set_event);
|
1523
|
+
}
|
1524
|
+
}
|
1525
|
+
|
1526
|
+
onpermissionchanged(permission_changed_event: PermissionChangedEvent){
|
1505
1527
|
if (this.verbose && window && window.console) {
|
1506
|
-
console.log(
|
1528
|
+
console.log(permission_changed_event);
|
1507
1529
|
}
|
1508
1530
|
}
|
1509
1531
|
|
1510
|
-
|
1532
|
+
ontokensent(tokenSentEvent: TokenSentEvent) {
|
1511
1533
|
if (this.verbose && window && window.console) {
|
1512
|
-
console.log(
|
1534
|
+
console.log(tokenSentEvent);
|
1513
1535
|
}
|
1514
1536
|
}
|
1515
1537
|
|
@@ -1625,42 +1647,47 @@ export class DefaultSocket implements Socket {
|
|
1625
1647
|
|
1626
1648
|
async writeMessageReaction(id: string, clan_id: string, channel_id: string, mode: number, is_public: boolean, message_id: string, emoji_id: string, emoji: string, count: number, message_sender_id: string, action_delete: boolean): Promise<ApiMessageReaction> {
|
1627
1649
|
const response = await this.send({message_reaction_event: {id: id, clan_id: clan_id, channel_id: channel_id, mode: mode, is_public: is_public, message_id: message_id, emoji_id: emoji_id, emoji: emoji, count: count, message_sender_id: message_sender_id, action: action_delete}});
|
1628
|
-
return response.message_reaction_event
|
1650
|
+
return response.message_reaction_event;
|
1629
1651
|
}
|
1630
1652
|
|
1631
1653
|
async writeMessageTyping(clan_id: string, channel_id: string, mode: number, is_public: boolean): Promise<MessageTypingEvent> {
|
1632
1654
|
const response = await this.send({message_typing_event: {clan_id: clan_id, channel_id: channel_id, mode:mode, is_public: is_public}});
|
1633
|
-
return response.message_typing_event
|
1655
|
+
return response.message_typing_event;
|
1634
1656
|
}
|
1635
1657
|
|
1636
1658
|
async writeLastSeenMessage(clan_id: string, channel_id: string, mode: number, message_id: string, timestamp_seconds: number): Promise<LastSeenMessageEvent> {
|
1637
1659
|
const response = await this.send({last_seen_message_event: {clan_id: clan_id, channel_id: channel_id, mode: mode, message_id: message_id, timestamp_seconds: timestamp_seconds}});
|
1638
|
-
return response.last_seen_message_event
|
1660
|
+
return response.last_seen_message_event;
|
1639
1661
|
}
|
1640
1662
|
|
1641
1663
|
async writeLastPinMessage(clan_id: string, channel_id: string, mode: number, is_public: boolean, message_id: string, timestamp_seconds: number, operation: number): Promise<LastPinMessageEvent> {
|
1642
1664
|
const response = await this.send({last_pin_message_event: {clan_id: clan_id, channel_id: channel_id, mode: mode, is_public: is_public, message_id: message_id, timestamp_seconds: timestamp_seconds, operation: operation}});
|
1643
|
-
return response.last_pin_message_event
|
1665
|
+
return response.last_pin_message_event;
|
1644
1666
|
}
|
1645
1667
|
|
1646
1668
|
async writeVoiceJoined(id: string, clanId: string, clanName: string, voiceChannelId: string, voiceChannelLabel: string, participant: string, lastScreenshot: string): Promise<VoiceJoinedEvent> {
|
1647
1669
|
const response = await this.send({voice_joined_event: {clan_id: clanId, clan_name: clanName, id: id, participant: participant, voice_channel_id: voiceChannelId, voice_channel_label: voiceChannelLabel, last_screenshot: lastScreenshot}});
|
1648
|
-
return response.voice_joined_event
|
1670
|
+
return response.voice_joined_event;
|
1649
1671
|
}
|
1650
1672
|
|
1651
1673
|
async writeVoiceLeaved(id: string, clanId: string, voiceChannelId: string, voiceUserId: string): Promise<VoiceLeavedEvent> {
|
1652
1674
|
const response = await this.send({voice_leaved_event: {id: id, clan_id: clanId, voice_channel_id: voiceChannelId, voice_user_id: voiceUserId}});
|
1653
|
-
return response.voice_leaved_event
|
1675
|
+
return response.voice_leaved_event;
|
1654
1676
|
}
|
1655
1677
|
|
1656
1678
|
async writeCustomStatus(clan_id: string, status: string): Promise<CustomStatusEvent> {
|
1657
1679
|
const response = await this.send({custom_status_event: {clan_id: clan_id, status: status}});
|
1658
|
-
return response.custom_status_event
|
1680
|
+
return response.custom_status_event;
|
1659
1681
|
}
|
1660
1682
|
|
1661
1683
|
async checkDuplicateName(name: string, condition_id: string, type: number): Promise<CheckNameExistedEvent> {
|
1662
1684
|
const response = await this.send({check_name_existed_event: {name: name, condition_id: condition_id, type: type}});
|
1663
|
-
return response.check_name_existed_event
|
1685
|
+
return response.check_name_existed_event;
|
1686
|
+
}
|
1687
|
+
|
1688
|
+
async sendToken(receiver_id: string, amount: number) : Promise<TokenSentEvent> {
|
1689
|
+
const response = await this.send({token_sent_event: {receiver_id: receiver_id, amount: amount}});
|
1690
|
+
return response.token_sent_event;
|
1664
1691
|
}
|
1665
1692
|
|
1666
1693
|
private async pingPong(): Promise<void> {
|