mezon-js 2.9.64 → 2.9.65
Sign up to get free protection for your applications and to get access to all the features.
- package/api.gen.ts +54 -5
- package/client.ts +17 -0
- package/dist/api.gen.d.ts +10 -0
- package/dist/client.d.ts +2 -1
- package/dist/mezon-js.cjs.js +39 -6
- package/dist/mezon-js.esm.mjs +39 -6
- package/dist/socket.d.ts +3 -12
- package/package.json +1 -1
- package/socket.ts +4 -22
package/api.gen.ts
CHANGED
@@ -2148,6 +2148,20 @@ export interface ApiSystemMessagesList {
|
|
2148
2148
|
system_messages_list?: Array<ApiSystemMessage>;
|
2149
2149
|
}
|
2150
2150
|
|
2151
|
+
/** */
|
2152
|
+
export interface ApiTokenSentEvent {
|
2153
|
+
//
|
2154
|
+
amount?: number;
|
2155
|
+
//
|
2156
|
+
note?: string;
|
2157
|
+
//
|
2158
|
+
receiver_id?: string;
|
2159
|
+
//
|
2160
|
+
sender_id?: string;
|
2161
|
+
//
|
2162
|
+
sender_name?: string;
|
2163
|
+
}
|
2164
|
+
|
2151
2165
|
/** Update a user's account details. */
|
2152
2166
|
export interface ApiUpdateAccountRequest {
|
2153
2167
|
//
|
@@ -8280,12 +8294,47 @@ pushPubKey(bearerToken: string,
|
|
8280
8294
|
|
8281
8295
|
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
8282
8296
|
const fetchOptions = buildFetchOptions("POST", options, bodyJson);
|
8283
|
-
|
8284
|
-
|
8297
|
+
if (bearerToken) {
|
8298
|
+
fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
|
8299
|
+
}
|
8300
|
+
if (basicAuthUsername) {
|
8301
|
+
fetchOptions.headers["Authorization"] = "Basic " + encode(basicAuthUsername + ":" + basicAuthPassword);
|
8302
|
+
}
|
8303
|
+
|
8304
|
+
return Promise.race([
|
8305
|
+
fetch(fullUrl, fetchOptions).then((response) => {
|
8306
|
+
if (response.status == 204) {
|
8307
|
+
return response;
|
8308
|
+
} else if (response.status >= 200 && response.status < 300) {
|
8309
|
+
return response.json();
|
8310
|
+
} else {
|
8311
|
+
throw response;
|
8312
|
+
}
|
8313
|
+
}),
|
8314
|
+
new Promise((_, reject) =>
|
8315
|
+
setTimeout(reject, this.timeoutMs, "Request timed out.")
|
8316
|
+
),
|
8317
|
+
]);
|
8318
|
+
}
|
8319
|
+
|
8320
|
+
/** UpdateWallets */
|
8321
|
+
sendToken(bearerToken: string,
|
8322
|
+
body:ApiTokenSentEvent,
|
8323
|
+
options: any = {}): Promise<any> {
|
8324
|
+
|
8325
|
+
if (body === null || body === undefined) {
|
8326
|
+
throw new Error("'body' is a required parameter but is null or undefined.");
|
8285
8327
|
}
|
8286
|
-
|
8287
|
-
|
8288
|
-
|
8328
|
+
const urlPath = "/v2/sendtoken";
|
8329
|
+
const queryParams = new Map<string, any>();
|
8330
|
+
|
8331
|
+
let bodyJson : string = "";
|
8332
|
+
bodyJson = JSON.stringify(body || {});
|
8333
|
+
|
8334
|
+
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
8335
|
+
const fetchOptions = buildFetchOptions("POST", options, bodyJson);
|
8336
|
+
if (bearerToken) {
|
8337
|
+
fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
|
8289
8338
|
}
|
8290
8339
|
|
8291
8340
|
return Promise.race([
|
package/client.ts
CHANGED
@@ -137,6 +137,7 @@ import {
|
|
137
137
|
ApiPubKey,
|
138
138
|
ApiGetKeyServerResp,
|
139
139
|
MezonapiListAuditLog,
|
140
|
+
ApiTokenSentEvent,
|
140
141
|
} from "./api.gen";
|
141
142
|
|
142
143
|
import { Session } from "./session";
|
@@ -3516,6 +3517,22 @@ export class Client {
|
|
3516
3517
|
});
|
3517
3518
|
}
|
3518
3519
|
|
3520
|
+
async updateWallets(session: Session, request: ApiTokenSentEvent) {
|
3521
|
+
if (
|
3522
|
+
this.autoRefreshSession &&
|
3523
|
+
session.refresh_token &&
|
3524
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
3525
|
+
) {
|
3526
|
+
await this.sessionRefresh(session);
|
3527
|
+
}
|
3528
|
+
|
3529
|
+
return this.apiClient
|
3530
|
+
.sendToken(session.token, request)
|
3531
|
+
.then((response: ApiTokenSentEvent) => {
|
3532
|
+
return Promise.resolve(response);
|
3533
|
+
});
|
3534
|
+
}
|
3535
|
+
|
3519
3536
|
async listStreamingChannels(
|
3520
3537
|
session: Session,
|
3521
3538
|
clanId: string
|
package/dist/api.gen.d.ts
CHANGED
@@ -1252,6 +1252,14 @@ export interface ApiSystemMessageRequest {
|
|
1252
1252
|
export interface ApiSystemMessagesList {
|
1253
1253
|
system_messages_list?: Array<ApiSystemMessage>;
|
1254
1254
|
}
|
1255
|
+
/** */
|
1256
|
+
export interface ApiTokenSentEvent {
|
1257
|
+
amount?: number;
|
1258
|
+
note?: string;
|
1259
|
+
receiver_id?: string;
|
1260
|
+
sender_id?: string;
|
1261
|
+
sender_name?: string;
|
1262
|
+
}
|
1255
1263
|
/** Update a user's account details. */
|
1256
1264
|
export interface ApiUpdateAccountRequest {
|
1257
1265
|
about_me?: string;
|
@@ -1709,6 +1717,8 @@ export declare class MezonApi {
|
|
1709
1717
|
rpcFunc2(bearerToken: string, basicAuthUsername: string, basicAuthPassword: string, id: string, payload?: string, httpKey?: string, options?: any): Promise<ApiRpc>;
|
1710
1718
|
/** Execute a Lua function on the server. */
|
1711
1719
|
rpcFunc(bearerToken: string, basicAuthUsername: string, basicAuthPassword: string, id: string, payload: string, httpKey?: string, options?: any): Promise<ApiRpc>;
|
1720
|
+
/** UpdateWallets */
|
1721
|
+
sendToken(bearerToken: string, body: ApiTokenSentEvent, options?: any): Promise<any>;
|
1712
1722
|
/** Log out a session, invalidate a refresh token, or log out all sessions/refresh tokens for a user. */
|
1713
1723
|
sessionLogout(bearerToken: string, body: ApiSessionLogoutRequest, options?: any): Promise<any>;
|
1714
1724
|
/** Add a new sticker */
|
package/dist/client.d.ts
CHANGED
@@ -13,7 +13,7 @@
|
|
13
13
|
* See the License for the specific language governing permissions and
|
14
14
|
* limitations under the License.
|
15
15
|
*/
|
16
|
-
import { ApiAccount, ApiAccountCustom, ApiAccountDevice, ApiAccountEmail, ApiAccountFacebook, ApiAccountFacebookInstantGame, ApiAccountGoogle, ApiAccountGameCenter, ApiAccountSteam, ApiChannelDescList, ApiChannelDescription, ApiCreateChannelDescRequest, ApiDeleteRoleRequest, ApiClanDescList, ApiCreateClanDescRequest, ApiClanDesc, ApiCategoryDesc, ApiCategoryDescList, ApiPermissionList, ApiRoleUserList, ApiRole, ApiCreateRoleRequest, ApiAddRoleChannelDescRequest, ApiCreateCategoryDescRequest, ApiUpdateCategoryDescRequest, ApiEvent, ApiUpdateAccountRequest, ApiAccountApple, ApiLinkSteamRequest, ApiClanDescProfile, ApiClanProfile, ApiChannelUserList, ApiClanUserList, ApiLinkInviteUserRequest, ApiUpdateEventRequest, ApiLinkInviteUser, ApiInviteUserRes, ApiUploadAttachmentRequest, ApiUploadAttachment, ApiMessageReaction, ApiMessageMention, ApiMessageAttachment, ApiMessageRef, ApiChannelMessageHeader, ApiVoiceChannelUserList, ApiChannelAttachmentList, ApiCreateEventRequest, ApiEventManagement, ApiEventList, ApiDeleteEventRequest, ApiSetDefaultNotificationRequest, ApiSetNotificationRequest, ApiSetMuteNotificationRequest, ApiSearchMessageRequest, ApiSearchMessageResponse, ApiPinMessageRequest, ApiPinMessagesList, ApiDeleteChannelDescRequest, ApiChangeChannelPrivateRequest, ApiClanEmojiCreateRequest, MezonUpdateClanEmojiByIdBody, ApiWebhookCreateRequest, ApiWebhookListResponse, MezonUpdateWebhookByIdBody, ApiWebhookGenerateResponse, ApiCheckDuplicateClanNameResponse, ApiClanStickerAddRequest, MezonUpdateClanStickerByIdBody, MezonChangeChannelCategoryBody, ApiUpdateRoleChannelRequest, ApiAddAppRequest, ApiAppList, ApiApp, MezonUpdateAppBody, ApiSystemMessagesList, ApiSystemMessage, ApiSystemMessageRequest, MezonUpdateSystemMessageBody, ApiUpdateCategoryOrderRequest, ApiGiveCoffeeEvent, ApiListStreamingChannelsResponse, ApiStreamingChannelUserList, ApiRegisterStreamingChannelRequest, ApiRoleList, ApiListChannelAppsResponse, ApiNotificationChannelCategorySettingList, ApiNotificationUserChannel, ApiNotificationSetting, ApiNotifiReactMessage, ApiHashtagDmList, ApiEmojiListedResponse, ApiStickerListedResponse, ApiAllUsersAddChannelResponse, ApiRoleListEventResponse, ApiAllUserClans, ApiUserPermissionInChannelListResponse, ApiPermissionRoleChannelListEventResponse, ApiMarkAsReadRequest, ApiEditChannelCanvasRequest, ApiChannelSettingListResponse, ApiAddFavoriteChannelResponse, ApiRegistFcmDeviceTokenResponse, ApiListUserActivity, ApiCreateActivityRequest, ApiLoginIDResponse, ApiLoginRequest, ApiConfirmLoginRequest, ApiUserActivity, ApiChanEncryptionMethod, ApiGetPubKeysResponse, ApiPubKey, ApiGetKeyServerResp, MezonapiListAuditLog } from "./api.gen";
|
16
|
+
import { ApiAccount, ApiAccountCustom, ApiAccountDevice, ApiAccountEmail, ApiAccountFacebook, ApiAccountFacebookInstantGame, ApiAccountGoogle, ApiAccountGameCenter, ApiAccountSteam, ApiChannelDescList, ApiChannelDescription, ApiCreateChannelDescRequest, ApiDeleteRoleRequest, ApiClanDescList, ApiCreateClanDescRequest, ApiClanDesc, ApiCategoryDesc, ApiCategoryDescList, ApiPermissionList, ApiRoleUserList, ApiRole, ApiCreateRoleRequest, ApiAddRoleChannelDescRequest, ApiCreateCategoryDescRequest, ApiUpdateCategoryDescRequest, ApiEvent, ApiUpdateAccountRequest, ApiAccountApple, ApiLinkSteamRequest, ApiClanDescProfile, ApiClanProfile, ApiChannelUserList, ApiClanUserList, ApiLinkInviteUserRequest, ApiUpdateEventRequest, ApiLinkInviteUser, ApiInviteUserRes, ApiUploadAttachmentRequest, ApiUploadAttachment, ApiMessageReaction, ApiMessageMention, ApiMessageAttachment, ApiMessageRef, ApiChannelMessageHeader, ApiVoiceChannelUserList, ApiChannelAttachmentList, ApiCreateEventRequest, ApiEventManagement, ApiEventList, ApiDeleteEventRequest, ApiSetDefaultNotificationRequest, ApiSetNotificationRequest, ApiSetMuteNotificationRequest, ApiSearchMessageRequest, ApiSearchMessageResponse, ApiPinMessageRequest, ApiPinMessagesList, ApiDeleteChannelDescRequest, ApiChangeChannelPrivateRequest, ApiClanEmojiCreateRequest, MezonUpdateClanEmojiByIdBody, ApiWebhookCreateRequest, ApiWebhookListResponse, MezonUpdateWebhookByIdBody, ApiWebhookGenerateResponse, ApiCheckDuplicateClanNameResponse, ApiClanStickerAddRequest, MezonUpdateClanStickerByIdBody, MezonChangeChannelCategoryBody, ApiUpdateRoleChannelRequest, ApiAddAppRequest, ApiAppList, ApiApp, MezonUpdateAppBody, ApiSystemMessagesList, ApiSystemMessage, ApiSystemMessageRequest, MezonUpdateSystemMessageBody, ApiUpdateCategoryOrderRequest, ApiGiveCoffeeEvent, ApiListStreamingChannelsResponse, ApiStreamingChannelUserList, ApiRegisterStreamingChannelRequest, ApiRoleList, ApiListChannelAppsResponse, ApiNotificationChannelCategorySettingList, ApiNotificationUserChannel, ApiNotificationSetting, ApiNotifiReactMessage, ApiHashtagDmList, ApiEmojiListedResponse, ApiStickerListedResponse, ApiAllUsersAddChannelResponse, ApiRoleListEventResponse, ApiAllUserClans, ApiUserPermissionInChannelListResponse, ApiPermissionRoleChannelListEventResponse, ApiMarkAsReadRequest, ApiEditChannelCanvasRequest, ApiChannelSettingListResponse, ApiAddFavoriteChannelResponse, ApiRegistFcmDeviceTokenResponse, ApiListUserActivity, ApiCreateActivityRequest, ApiLoginIDResponse, ApiLoginRequest, ApiConfirmLoginRequest, ApiUserActivity, ApiChanEncryptionMethod, ApiGetPubKeysResponse, ApiPubKey, ApiGetKeyServerResp, MezonapiListAuditLog, ApiTokenSentEvent } from "./api.gen";
|
17
17
|
import { Session } from "./session";
|
18
18
|
import { Socket } from "./socket";
|
19
19
|
import { WebSocketAdapter } from "./web_socket_adapter";
|
@@ -559,6 +559,7 @@ export declare class Client {
|
|
559
559
|
updateCategoryOrder(session: Session, request: ApiUpdateCategoryOrderRequest): Promise<any>;
|
560
560
|
deleteCategoryOrder(session: Session, clanId: string): Promise<any>;
|
561
561
|
givecoffee(session: Session, request: ApiGiveCoffeeEvent): Promise<boolean>;
|
562
|
+
updateWallets(session: Session, request: ApiTokenSentEvent): Promise<ApiTokenSentEvent>;
|
562
563
|
listStreamingChannels(session: Session, clanId: string): Promise<ApiListStreamingChannelsResponse>;
|
563
564
|
/** List a channel's users. */
|
564
565
|
listStreamingChannelUsers(session: Session, clanId: string, channelId: string, channelType: number, state?: number, limit?: number, cursor?: string): Promise<ApiStreamingChannelUserList>;
|
package/dist/mezon-js.cjs.js
CHANGED
@@ -5287,6 +5287,35 @@ var MezonApi = class {
|
|
5287
5287
|
)
|
5288
5288
|
]);
|
5289
5289
|
}
|
5290
|
+
/** UpdateWallets */
|
5291
|
+
sendToken(bearerToken, body, options = {}) {
|
5292
|
+
if (body === null || body === void 0) {
|
5293
|
+
throw new Error("'body' is a required parameter but is null or undefined.");
|
5294
|
+
}
|
5295
|
+
const urlPath = "/v2/sendtoken";
|
5296
|
+
const queryParams = /* @__PURE__ */ new Map();
|
5297
|
+
let bodyJson = "";
|
5298
|
+
bodyJson = JSON.stringify(body || {});
|
5299
|
+
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
5300
|
+
const fetchOptions = buildFetchOptions("POST", options, bodyJson);
|
5301
|
+
if (bearerToken) {
|
5302
|
+
fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
|
5303
|
+
}
|
5304
|
+
return Promise.race([
|
5305
|
+
fetch(fullUrl, fetchOptions).then((response) => {
|
5306
|
+
if (response.status == 204) {
|
5307
|
+
return response;
|
5308
|
+
} else if (response.status >= 200 && response.status < 300) {
|
5309
|
+
return response.json();
|
5310
|
+
} else {
|
5311
|
+
throw response;
|
5312
|
+
}
|
5313
|
+
}),
|
5314
|
+
new Promise(
|
5315
|
+
(_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
|
5316
|
+
)
|
5317
|
+
]);
|
5318
|
+
}
|
5290
5319
|
/** Log out a session, invalidate a refresh token, or log out all sessions/refresh tokens for a user. */
|
5291
5320
|
sessionLogout(bearerToken, body, options = {}) {
|
5292
5321
|
if (body === null || body === void 0) {
|
@@ -6992,12 +7021,6 @@ var _DefaultSocket = class _DefaultSocket {
|
|
6992
7021
|
return response.check_name_existed_event;
|
6993
7022
|
});
|
6994
7023
|
}
|
6995
|
-
sendToken(receiver_id, amount) {
|
6996
|
-
return __async(this, null, function* () {
|
6997
|
-
const response = yield this.send({ token_sent_event: { receiver_id, amount } });
|
6998
|
-
return response.token_sent_event;
|
6999
|
-
});
|
7000
|
-
}
|
7001
7024
|
pingPong() {
|
7002
7025
|
return __async(this, null, function* () {
|
7003
7026
|
if (!this.adapter.isOpen()) {
|
@@ -8865,6 +8888,16 @@ var Client = class {
|
|
8865
8888
|
});
|
8866
8889
|
});
|
8867
8890
|
}
|
8891
|
+
updateWallets(session, request) {
|
8892
|
+
return __async(this, null, function* () {
|
8893
|
+
if (this.autoRefreshSession && session.refresh_token && session.isexpired((Date.now() + this.expiredTimespanMs) / 1e3)) {
|
8894
|
+
yield this.sessionRefresh(session);
|
8895
|
+
}
|
8896
|
+
return this.apiClient.sendToken(session.token, request).then((response) => {
|
8897
|
+
return Promise.resolve(response);
|
8898
|
+
});
|
8899
|
+
});
|
8900
|
+
}
|
8868
8901
|
listStreamingChannels(session, clanId) {
|
8869
8902
|
return __async(this, null, function* () {
|
8870
8903
|
if (this.autoRefreshSession && session.refresh_token && session.isexpired((Date.now() + this.expiredTimespanMs) / 1e3)) {
|
package/dist/mezon-js.esm.mjs
CHANGED
@@ -5258,6 +5258,35 @@ var MezonApi = class {
|
|
5258
5258
|
)
|
5259
5259
|
]);
|
5260
5260
|
}
|
5261
|
+
/** UpdateWallets */
|
5262
|
+
sendToken(bearerToken, body, options = {}) {
|
5263
|
+
if (body === null || body === void 0) {
|
5264
|
+
throw new Error("'body' is a required parameter but is null or undefined.");
|
5265
|
+
}
|
5266
|
+
const urlPath = "/v2/sendtoken";
|
5267
|
+
const queryParams = /* @__PURE__ */ new Map();
|
5268
|
+
let bodyJson = "";
|
5269
|
+
bodyJson = JSON.stringify(body || {});
|
5270
|
+
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
5271
|
+
const fetchOptions = buildFetchOptions("POST", options, bodyJson);
|
5272
|
+
if (bearerToken) {
|
5273
|
+
fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
|
5274
|
+
}
|
5275
|
+
return Promise.race([
|
5276
|
+
fetch(fullUrl, fetchOptions).then((response) => {
|
5277
|
+
if (response.status == 204) {
|
5278
|
+
return response;
|
5279
|
+
} else if (response.status >= 200 && response.status < 300) {
|
5280
|
+
return response.json();
|
5281
|
+
} else {
|
5282
|
+
throw response;
|
5283
|
+
}
|
5284
|
+
}),
|
5285
|
+
new Promise(
|
5286
|
+
(_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
|
5287
|
+
)
|
5288
|
+
]);
|
5289
|
+
}
|
5261
5290
|
/** Log out a session, invalidate a refresh token, or log out all sessions/refresh tokens for a user. */
|
5262
5291
|
sessionLogout(bearerToken, body, options = {}) {
|
5263
5292
|
if (body === null || body === void 0) {
|
@@ -6963,12 +6992,6 @@ var _DefaultSocket = class _DefaultSocket {
|
|
6963
6992
|
return response.check_name_existed_event;
|
6964
6993
|
});
|
6965
6994
|
}
|
6966
|
-
sendToken(receiver_id, amount) {
|
6967
|
-
return __async(this, null, function* () {
|
6968
|
-
const response = yield this.send({ token_sent_event: { receiver_id, amount } });
|
6969
|
-
return response.token_sent_event;
|
6970
|
-
});
|
6971
|
-
}
|
6972
6995
|
pingPong() {
|
6973
6996
|
return __async(this, null, function* () {
|
6974
6997
|
if (!this.adapter.isOpen()) {
|
@@ -8836,6 +8859,16 @@ var Client = class {
|
|
8836
8859
|
});
|
8837
8860
|
});
|
8838
8861
|
}
|
8862
|
+
updateWallets(session, request) {
|
8863
|
+
return __async(this, null, function* () {
|
8864
|
+
if (this.autoRefreshSession && session.refresh_token && session.isexpired((Date.now() + this.expiredTimespanMs) / 1e3)) {
|
8865
|
+
yield this.sessionRefresh(session);
|
8866
|
+
}
|
8867
|
+
return this.apiClient.sendToken(session.token, request).then((response) => {
|
8868
|
+
return Promise.resolve(response);
|
8869
|
+
});
|
8870
|
+
});
|
8871
|
+
}
|
8839
8872
|
listStreamingChannels(session, clanId) {
|
8840
8873
|
return __async(this, null, function* () {
|
8841
8874
|
if (this.autoRefreshSession && session.refresh_token && session.isexpired((Date.now() + this.expiredTimespanMs) / 1e3)) {
|
package/dist/socket.d.ts
CHANGED
@@ -13,7 +13,7 @@
|
|
13
13
|
* See the License for the specific language governing permissions and
|
14
14
|
* limitations under the License.
|
15
15
|
*/
|
16
|
-
import { ApiChannelMessageHeader, ApiCreateEventRequest, ApiGiveCoffeeEvent, ApiMessageAttachment, ApiMessageMention, ApiMessageReaction, ApiMessageRef, ApiPermissionUpdate, ApiRole, ApiRpc } from "./api.gen";
|
16
|
+
import { ApiChannelMessageHeader, ApiCreateEventRequest, ApiGiveCoffeeEvent, ApiMessageAttachment, ApiMessageMention, ApiMessageReaction, ApiMessageRef, ApiPermissionUpdate, ApiRole, ApiRpc, ApiTokenSentEvent } from "./api.gen";
|
17
17
|
import { Session } from "./session";
|
18
18
|
import { ChannelMessage, Notification } from "./client";
|
19
19
|
import { WebSocketAdapter } from "./web_socket_adapter";
|
@@ -577,12 +577,6 @@ export interface PermissionChangedEvent {
|
|
577
577
|
user_id: string;
|
578
578
|
channel_id: string;
|
579
579
|
}
|
580
|
-
export interface TokenSentEvent {
|
581
|
-
sender_id: string;
|
582
|
-
sender_name: string;
|
583
|
-
receiver_id: string;
|
584
|
-
amount: number;
|
585
|
-
}
|
586
580
|
export interface MessageButtonClicked {
|
587
581
|
message_id: string;
|
588
582
|
channel_id: string;
|
@@ -632,8 +626,6 @@ export interface Socket {
|
|
632
626
|
writeVoiceJoined(id: string, clanId: string, clanName: string, voiceChannelId: string, voiceChannelLabel: string, participant: string, lastScreenshot: string): Promise<VoiceJoinedEvent>;
|
633
627
|
/** send voice leaved */
|
634
628
|
writeVoiceLeaved(id: string, clanId: string, voiceChannelId: string, voiceUserId: string): Promise<VoiceLeavedEvent>;
|
635
|
-
/** send token */
|
636
|
-
sendToken(receiver_id: string, amount: number): Promise<TokenSentEvent>;
|
637
629
|
/** Handle disconnect events received from the socket. */
|
638
630
|
ondisconnect: (evt: Event) => void;
|
639
631
|
/** Handle error events received from the socket. */
|
@@ -704,7 +696,7 @@ export interface Socket {
|
|
704
696
|
onpermissionset: (permission_set_event: PermissionSet) => void;
|
705
697
|
onpermissionchanged: (permission_changed_event: PermissionChangedEvent) => void;
|
706
698
|
onunmuteevent: (unmute_event: UnmuteEvent) => void;
|
707
|
-
ontokensent: (token:
|
699
|
+
ontokensent: (token: ApiTokenSentEvent) => void;
|
708
700
|
}
|
709
701
|
/** Reports an error received from a socket message. */
|
710
702
|
export interface SocketError {
|
@@ -778,7 +770,7 @@ export declare class DefaultSocket implements Socket {
|
|
778
770
|
onpermissionset(permission_set_event: PermissionSet): void;
|
779
771
|
onpermissionchanged(permission_changed_event: PermissionChangedEvent): void;
|
780
772
|
onunmuteevent(unmute_event: UnmuteEvent): void;
|
781
|
-
ontokensent(tokenSentEvent:
|
773
|
+
ontokensent(tokenSentEvent: ApiTokenSentEvent): void;
|
782
774
|
handleMessageButtonClick(messageButtonClicked: MessageButtonClicked): void;
|
783
775
|
send(message: ChannelJoin | ChannelLeave | ChannelMessageSend | ChannelMessageUpdate | CustomStatusEvent | ChannelMessageRemove | MessageTypingEvent | LastSeenMessageEvent | Rpc | StatusFollow | StatusUnfollow | StatusUpdate | Ping, sendTimeout?: number): Promise<any>;
|
784
776
|
followUsers(userIds: string[]): Promise<Status>;
|
@@ -799,7 +791,6 @@ export declare class DefaultSocket implements Socket {
|
|
799
791
|
writeVoiceLeaved(id: string, clanId: string, voiceChannelId: string, voiceUserId: string): Promise<VoiceLeavedEvent>;
|
800
792
|
writeCustomStatus(clan_id: string, status: string): Promise<CustomStatusEvent>;
|
801
793
|
checkDuplicateName(name: string, condition_id: string, type: number): Promise<CheckNameExistedEvent>;
|
802
|
-
sendToken(receiver_id: string, amount: number): Promise<TokenSentEvent>;
|
803
794
|
private pingPong;
|
804
795
|
}
|
805
796
|
export {};
|
package/package.json
CHANGED
package/socket.ts
CHANGED
@@ -14,7 +14,7 @@
|
|
14
14
|
* limitations under the License.
|
15
15
|
*/
|
16
16
|
|
17
|
-
import { ApiChannelMessageHeader, ApiCreateEventRequest, ApiGiveCoffeeEvent, ApiMessageAttachment, ApiMessageMention, ApiMessageReaction, ApiMessageRef, ApiNotification, ApiPermissionUpdate, ApiRole, ApiRpc } from "./api.gen";
|
17
|
+
import { ApiChannelMessageHeader, ApiCreateEventRequest, ApiGiveCoffeeEvent, ApiMessageAttachment, ApiMessageMention, ApiMessageReaction, ApiMessageRef, ApiNotification, ApiPermissionUpdate, ApiRole, ApiRpc, ApiTokenSentEvent } from "./api.gen";
|
18
18
|
import { Session } from "./session";
|
19
19
|
import { ChannelMessage, Notification } from "./client";
|
20
20
|
import { WebSocketAdapter, WebSocketAdapterText } from "./web_socket_adapter";
|
@@ -808,16 +808,6 @@ export interface PermissionChangedEvent{
|
|
808
808
|
channel_id: string;
|
809
809
|
}
|
810
810
|
|
811
|
-
export interface TokenSentEvent {
|
812
|
-
// sender id
|
813
|
-
sender_id: string;
|
814
|
-
// sender name
|
815
|
-
sender_name: string;
|
816
|
-
// receiver
|
817
|
-
receiver_id: string;
|
818
|
-
// amount of token
|
819
|
-
amount: number;
|
820
|
-
}
|
821
811
|
export interface MessageButtonClicked {
|
822
812
|
message_id: string;
|
823
813
|
channel_id: string;
|
@@ -888,9 +878,6 @@ export interface Socket {
|
|
888
878
|
/** send voice leaved */
|
889
879
|
writeVoiceLeaved(id: string, clanId: string, voiceChannelId: string, voiceUserId: string) : Promise<VoiceLeavedEvent>;
|
890
880
|
|
891
|
-
/** send token */
|
892
|
-
sendToken(receiver_id: string, amount: number) : Promise<TokenSentEvent>;
|
893
|
-
|
894
881
|
/** Handle disconnect events received from the socket. */
|
895
882
|
ondisconnect: (evt: Event) => void;
|
896
883
|
|
@@ -1025,7 +1012,7 @@ export interface Socket {
|
|
1025
1012
|
|
1026
1013
|
onunmuteevent: (unmute_event: UnmuteEvent) => void;
|
1027
1014
|
|
1028
|
-
ontokensent: (token:
|
1015
|
+
ontokensent: (token: ApiTokenSentEvent) => void;
|
1029
1016
|
}
|
1030
1017
|
|
1031
1018
|
/** Reports an error received from a socket message. */
|
@@ -1232,7 +1219,7 @@ export class DefaultSocket implements Socket {
|
|
1232
1219
|
} else if(message.unmute_event){
|
1233
1220
|
this.onunmuteevent(<UnmuteEvent>message.unmute_event);
|
1234
1221
|
} else if (message.token_sent_event) {
|
1235
|
-
this.ontokensent(<
|
1222
|
+
this.ontokensent(<ApiTokenSentEvent>message.token_sent_event);
|
1236
1223
|
} else if (message.message_button_clicked){
|
1237
1224
|
this.handleMessageButtonClick(<MessageButtonClicked>message.message_button_clicked)
|
1238
1225
|
} else {
|
@@ -1561,7 +1548,7 @@ export class DefaultSocket implements Socket {
|
|
1561
1548
|
}
|
1562
1549
|
}
|
1563
1550
|
|
1564
|
-
ontokensent(tokenSentEvent:
|
1551
|
+
ontokensent(tokenSentEvent: ApiTokenSentEvent) {
|
1565
1552
|
if (this.verbose && window && window.console) {
|
1566
1553
|
console.log(tokenSentEvent);
|
1567
1554
|
}
|
@@ -1723,11 +1710,6 @@ export class DefaultSocket implements Socket {
|
|
1723
1710
|
return response.check_name_existed_event;
|
1724
1711
|
}
|
1725
1712
|
|
1726
|
-
async sendToken(receiver_id: string, amount: number) : Promise<TokenSentEvent> {
|
1727
|
-
const response = await this.send({token_sent_event: {receiver_id: receiver_id, amount: amount}});
|
1728
|
-
return response.token_sent_event;
|
1729
|
-
}
|
1730
|
-
|
1731
1713
|
private async pingPong(): Promise<void> {
|
1732
1714
|
if (!this.adapter.isOpen()) {
|
1733
1715
|
return;
|