浏览代码

fix merge error

Paul 5 年前
父节点
当前提交
1b27c1abaf
共有 5 个文件被更改,包括 13 次插入22 次删除
  1. 3
    3
      example/main.ts
  2. 4
    4
      package.json
  3. 3
    3
      src/client.ts
  4. 2
    2
      src/index.ts
  5. 1
    10
      src/types/callback.ts

+ 3
- 3
example/main.ts 查看文件

@@ -1,4 +1,4 @@
1
-import { Client } from '../src/client';
1
+import { Client, WebSocketResp } from '../src/client';
2 2
 import { WebsocketError } from './error';
3 3
 
4 4
 const url = 'ws://127.0.0.1:8081';
@@ -7,7 +7,7 @@ const client = new Client(url, {
7 7
     client
8 8
       .ping({})
9 9
       .then(
10
-        (res: string): void => {
10
+        (res: WebSocketResp): void => {
11 11
           console.log('ping sucessful:', res);
12 12
         },
13 13
       )
@@ -20,7 +20,7 @@ const client = new Client(url, {
20 20
     client
21 21
       .request('/v1/healthy', {})
22 22
       .then(
23
-        (res: string): void => {
23
+        (res: WebSocketResp): void => {
24 24
           console.log('request successful:', res);
25 25
         },
26 26
       )

+ 4
- 4
package.json 查看文件

@@ -21,8 +21,7 @@
21 21
   "license": "private",
22 22
   "dependencies": {
23 23
     "crypto-js": "^3.1.9-1",
24
-    "node-int64": "^0.4.0",
25
-    "rimraf": "^2.6.3"
24
+    "node-int64": "^0.4.0"
26 25
   },
27 26
   "devDependencies": {
28 27
     "@babel/cli": "^7.4.4",
@@ -47,11 +46,12 @@
47 46
     "eslint-loader": "^2.1.2",
48 47
     "html-webpack-plugin": "^3.2.0",
49 48
     "jest": "^24.5.0",
49
+    "webpack-dev-server": "^3.3.1",
50
+    "rimraf": "^2.6.3",
50 51
     "ts-jest": "^24.0.0",
51 52
     "typescript": "^3.3.4000",
52 53
     "webpack": "^4.30.0",
53
-    "webpack-cli": "^3.3.2",
54
-    "webpack-dev-server": "^3.3.1"
54
+    "webpack-cli": "^3.3.2"
55 55
   },
56 56
   "files": [
57 57
     "dist/"

+ 3
- 3
src/client.ts 查看文件

@@ -317,7 +317,7 @@ class Client {
317 317
   /**
318 318
    * 断线重连
319 319
    */
320
-  reconnect(): void {
320
+  private reconnect(): void {
321 321
     if (!this.reconnectLock) {
322 322
       this.reconnectLock = true;
323 323
       if (this._enableLogger) {
@@ -361,7 +361,7 @@ class Client {
361 361
    * @param param 请求参数,比如{"hello":"world"}
362 362
    * @param callback 请求状态回调处理
363 363
    */
364
-  asyncSend(operator: string, param: object): Promise<WebSocketResp> {
364
+  private asyncSend(operator: string, param: object): Promise<WebSocketResp> {
365 365
     return new Promise(
366 366
       (
367 367
         resolve: (data: WebSocketResp) => void,
@@ -420,7 +420,7 @@ class Client {
420 420
 
421 421
 let client: Client;
422 422
 
423
-function getClient(url: string, callback: ReadyStateCallback) {
423
+function getClient(url: string, callback: ReadyStateCallback): Client {
424 424
   if (!client) {
425 425
     client = new Client(url, callback);
426 426
   }

+ 2
- 2
src/index.ts 查看文件

@@ -1,3 +1,3 @@
1
-export { WebSocketClient } from './WebSocketClient';
2 1
 export { WebsocketError } from './error';
3
-export { Client } from './client';
2
+export { Client, WebSocketResp, getClient } from './client';
3
+export { ReadyStateCallback } from './types/callback';

+ 1
- 10
src/types/callback.ts 查看文件

@@ -1,14 +1,5 @@
1
-interface ReadyStateCallback {
1
+export interface ReadyStateCallback {
2 2
   onOpen(ev: Event): void;
3 3
   onError(ev: Event): void;
4 4
   onClose(ev: Event): void;
5 5
 }
6
-
7
-interface RequestCallback {
8
-  onStart(): void;
9
-  onSuccess(data: string): void;
10
-  onError(code: number, message: string): void;
11
-  onEnd(): void;
12
-}
13
-
14
-export { ReadyStateCallback, RequestCallback };