wx-chevalier il y a 5 ans
Parent
révision
c3ca62c674

+ 23
- 4
packages/cts-api/dist/cjs/api/WsApi.js Voir le fichier

@@ -1,4 +1,17 @@
1 1
 "use strict";
2
+var __extends = (this && this.__extends) || (function () {
3
+    var extendStatics = function (d, b) {
4
+        extendStatics = Object.setPrototypeOf ||
5
+            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7
+        return extendStatics(d, b);
8
+    };
9
+    return function (d, b) {
10
+        extendStatics(d, b);
11
+        function __() { this.constructor = d; }
12
+        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13
+    };
14
+})();
2 15
 var __assign = (this && this.__assign) || function () {
3 16
     __assign = Object.assign || function(t) {
4 17
         for (var s, i = 1, n = arguments.length; i < n; i++) {
@@ -46,15 +59,17 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
46 59
     }
47 60
 };
48 61
 Object.defineProperty(exports, "__esModule", { value: true });
62
+var WebSocketClient_1 = require("./../WebSocketClient");
49 63
 var CmdMsg_1 = require("../protocol/CmdMsg");
50
-var WsApi = (function () {
64
+var WsApi = (function (_super) {
65
+    __extends(WsApi, _super);
51 66
     function WsApi() {
67
+        return _super !== null && _super.apply(this, arguments) || this;
52 68
     }
53 69
     WsApi.prototype.sendMsg = function (msg) {
54 70
         return __awaiter(this, void 0, void 0, function () {
55 71
             return __generator(this, function (_a) {
56
-                console.log(msg);
57
-                return [2];
72
+                return [2, this.sendMessage(msg)];
58 73
             });
59 74
         });
60 75
     };
@@ -102,6 +117,10 @@ var WsApi = (function () {
102 117
     WsApi.prototype.removeBlackList = function (userIds) {
103 118
         return this.sendPostCmdMsg('removeBlackList', userIds);
104 119
     };
120
+    WsApi.prototype.deleteConversation = function (contactId, delete_message) {
121
+        if (delete_message === void 0) { delete_message = false; }
122
+        return this.request('/v1/delete/conversation', { contact: contactId, delete_message: delete_message });
123
+    };
105 124
     WsApi.prototype.listGroups = function () {
106 125
         return this.sendGetCmdMsg('listGroups');
107 126
     };
@@ -153,5 +172,5 @@ var WsApi = (function () {
153 172
         return this.sendPostCmdMsg('quitRoom', [roomId]);
154 173
     };
155 174
     return WsApi;
156
-}());
175
+}(WebSocketClient_1.WebSocketClient));
157 176
 exports.WsApi = WsApi;

+ 2
- 0
packages/cts-api/dist/cjs/index.js Voir le fichier

@@ -1,4 +1,6 @@
1 1
 "use strict";
2 2
 Object.defineProperty(exports, "__esModule", { value: true });
3
+var WsApi_1 = require("./api/WsApi");
4
+exports.WsApi = WsApi_1.WsApi;
3 5
 var WebSocketClient_1 = require("./WebSocketClient");
4 6
 exports.WebSocketClient = WebSocketClient_1.WebSocketClient;

+ 4
- 4
packages/cts-api/dist/index.js
Fichier diff supprimé car celui-ci est trop grand
Voir le fichier


+ 28
- 26
packages/cts-api/dist/types/api/WsApi.d.ts Voir le fichier

@@ -1,30 +1,32 @@
1
+import { WebSocketClient } from './../WebSocketClient';
1 2
 import { MsgBase, GroupOption } from '../protocol/MsgBase';
2
-export declare class WsApi {
3
+export declare class WsApi extends WebSocketClient {
3 4
     token: string;
4 5
     from: string;
5
-    sendMsg(msg: Partial<MsgBase>): Promise<void>;
6
-    sendGetCmdMsg(action: string, extra?: {}): Promise<void>;
7
-    sendPostCmdMsg(action: string, userIds: string[] | null, extra?: {}): Promise<void>;
8
-    getRoster(): Promise<void>;
9
-    addFriends(userIds: string[]): Promise<void>;
10
-    agreeFriends(userIds: string[]): Promise<void>;
11
-    rejectFriends(userIds: string[]): Promise<void>;
12
-    removeFriends(userIds: string[]): Promise<void>;
13
-    getBlacklist(): Promise<void>;
14
-    addToBlackList(userIds: string[]): Promise<void>;
15
-    removeBlackList(userIds: string[]): Promise<void>;
16
-    listGroups(): Promise<void>;
17
-    queryGroupInfo(roomId: string): Promise<void>;
18
-    queryRoomMember(roomId: string): Promise<void>;
19
-    getGroupBlackList(roomId: string): Promise<void>;
20
-    createGroup(groupOption: GroupOption): Promise<void>;
21
-    changeGroupInfo(groupOption: GroupOption): Promise<void>;
22
-    addGroupMembers(roomId: string, userIds: string[]): Promise<void>;
23
-    addToGroupBlackList(roomId: string, userIds: string[]): Promise<void>;
24
-    destroyGroup(roomId: string): Promise<void>;
25
-    leaveGroup(roomId: string): Promise<void>;
26
-    createRoom(groupOption: GroupOption): Promise<void>;
27
-    listRooms(): Promise<void>;
28
-    joinRoom(roomId: string): Promise<void>;
29
-    quitRoom(roomId: string): Promise<void>;
6
+    sendMsg(msg: Partial<MsgBase>): Promise<import("ts-linker-sdk/dist/types/types").WebSocketResp>;
7
+    sendGetCmdMsg(action: string, extra?: {}): Promise<import("ts-linker-sdk/dist/types/types").WebSocketResp>;
8
+    sendPostCmdMsg(action: string, userIds: string[] | null, extra?: {}): Promise<import("ts-linker-sdk/dist/types/types").WebSocketResp>;
9
+    getRoster(): Promise<import("ts-linker-sdk/dist/types/types").WebSocketResp>;
10
+    addFriends(userIds: string[]): Promise<import("ts-linker-sdk/dist/types/types").WebSocketResp>;
11
+    agreeFriends(userIds: string[]): Promise<import("ts-linker-sdk/dist/types/types").WebSocketResp>;
12
+    rejectFriends(userIds: string[]): Promise<import("ts-linker-sdk/dist/types/types").WebSocketResp>;
13
+    removeFriends(userIds: string[]): Promise<import("ts-linker-sdk/dist/types/types").WebSocketResp>;
14
+    getBlacklist(): Promise<import("ts-linker-sdk/dist/types/types").WebSocketResp>;
15
+    addToBlackList(userIds: string[]): Promise<import("ts-linker-sdk/dist/types/types").WebSocketResp>;
16
+    removeBlackList(userIds: string[]): Promise<import("ts-linker-sdk/dist/types/types").WebSocketResp>;
17
+    deleteConversation(contactId: string, delete_message?: boolean): Promise<import("ts-linker-sdk/dist/types/types").WebSocketResp>;
18
+    listGroups(): Promise<import("ts-linker-sdk/dist/types/types").WebSocketResp>;
19
+    queryGroupInfo(roomId: string): Promise<import("ts-linker-sdk/dist/types/types").WebSocketResp>;
20
+    queryRoomMember(roomId: string): Promise<import("ts-linker-sdk/dist/types/types").WebSocketResp>;
21
+    getGroupBlackList(roomId: string): Promise<import("ts-linker-sdk/dist/types/types").WebSocketResp>;
22
+    createGroup(groupOption: GroupOption): Promise<import("ts-linker-sdk/dist/types/types").WebSocketResp>;
23
+    changeGroupInfo(groupOption: GroupOption): Promise<import("ts-linker-sdk/dist/types/types").WebSocketResp>;
24
+    addGroupMembers(roomId: string, userIds: string[]): Promise<import("ts-linker-sdk/dist/types/types").WebSocketResp>;
25
+    addToGroupBlackList(roomId: string, userIds: string[]): Promise<import("ts-linker-sdk/dist/types/types").WebSocketResp>;
26
+    destroyGroup(roomId: string): Promise<import("ts-linker-sdk/dist/types/types").WebSocketResp>;
27
+    leaveGroup(roomId: string): Promise<import("ts-linker-sdk/dist/types/types").WebSocketResp>;
28
+    createRoom(groupOption: GroupOption): Promise<import("ts-linker-sdk/dist/types/types").WebSocketResp>;
29
+    listRooms(): Promise<import("ts-linker-sdk/dist/types/types").WebSocketResp>;
30
+    joinRoom(roomId: string): Promise<import("ts-linker-sdk/dist/types/types").WebSocketResp>;
31
+    quitRoom(roomId: string): Promise<import("ts-linker-sdk/dist/types/types").WebSocketResp>;
30 32
 }

+ 1
- 0
packages/cts-api/dist/types/index.d.ts Voir le fichier

@@ -1 +1,2 @@
1
+export { WsApi } from './api/WsApi';
1 2
 export { WebSocketClient } from './WebSocketClient';

+ 10
- 2
packages/cts-api/src/api/WsApi.ts Voir le fichier

@@ -1,14 +1,15 @@
1
+import { WebSocketClient } from './../WebSocketClient';
1 2
 import { MsgBase, GroupOption } from '../protocol/MsgBase';
2 3
 import { CmdMsg } from '../protocol/CmdMsg';
3 4
 
4 5
 /** WebSocket Api */
5
-export class WsApi {
6
+export class WsApi extends WebSocketClient {
6 7
   // 保存公共的状态信息
7 8
   token: string;
8 9
   from: string;
9 10
 
10 11
   async sendMsg(msg: Partial<MsgBase>) {
11
-    console.log(msg);
12
+    return this.sendMessage(msg);
12 13
   }
13 14
 
14 15
   /** @start 好友管理 */
@@ -73,6 +74,13 @@ export class WsApi {
73 74
 
74 75
   /** @end 好友管理 */
75 76
 
77
+  /** @start 会话管理 */
78
+  // 删除会话
79
+  deleteConversation(contactId: string, delete_message: boolean = false) {
80
+    return this.request('/v1/delete/conversation', { contact: contactId, delete_message });
81
+  }
82
+  /** @end 会话管理 */
83
+
76 84
   /** @start 群组管理 */
77 85
   // 列出所有的群组
78 86
   listGroups() {

+ 1
- 0
packages/cts-api/src/index.ts Voir le fichier

@@ -1 +1,2 @@
1
+export { WsApi } from './api/WsApi';
1 2
 export { WebSocketClient } from './WebSocketClient';