Browse Source

fix merge error

Paul 5 years ago
parent
commit
1b27c1abaf
5 changed files with 13 additions and 22 deletions
  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 View File

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

+ 4
- 4
package.json View File

21
   "license": "private",
21
   "license": "private",
22
   "dependencies": {
22
   "dependencies": {
23
     "crypto-js": "^3.1.9-1",
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
   "devDependencies": {
26
   "devDependencies": {
28
     "@babel/cli": "^7.4.4",
27
     "@babel/cli": "^7.4.4",
47
     "eslint-loader": "^2.1.2",
46
     "eslint-loader": "^2.1.2",
48
     "html-webpack-plugin": "^3.2.0",
47
     "html-webpack-plugin": "^3.2.0",
49
     "jest": "^24.5.0",
48
     "jest": "^24.5.0",
49
+    "webpack-dev-server": "^3.3.1",
50
+    "rimraf": "^2.6.3",
50
     "ts-jest": "^24.0.0",
51
     "ts-jest": "^24.0.0",
51
     "typescript": "^3.3.4000",
52
     "typescript": "^3.3.4000",
52
     "webpack": "^4.30.0",
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
   "files": [
56
   "files": [
57
     "dist/"
57
     "dist/"

+ 3
- 3
src/client.ts View File

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

+ 2
- 2
src/index.ts View File

1
-export { WebSocketClient } from './WebSocketClient';
2
 export { WebsocketError } from './error';
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 View File

1
-interface ReadyStateCallback {
1
+export interface ReadyStateCallback {
2
   onOpen(ev: Event): void;
2
   onOpen(ev: Event): void;
3
   onError(ev: Event): void;
3
   onError(ev: Event): void;
4
   onClose(ev: Event): void;
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 };