cmd-control-client-lib 3.0.42 → 3.0.45

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,12 +5,20 @@ import { MediaFile, MediaMd5 } from "./message";
5
5
  export declare type MayHaveChannelId = {
6
6
  channelId?: string;
7
7
  };
8
+ export declare enum ChannelMediaLinkState {
9
+ NONE = "NONE",
10
+ FREE = "FREE",
11
+ OFFER = "OFFER",
12
+ PAID = "PAID"
13
+ }
8
14
  /**
9
15
  * media info, may have a channel id
10
16
  */
11
17
  export declare class CMDC_CMEDIA implements ICOMMAND {
12
18
  action: ACTION;
13
- params: MayHaveChannelId & MediaFile;
19
+ params: MediaFile & MayHaveChannelId & {
20
+ linkState?: ChannelMediaLinkState;
21
+ };
14
22
  }
15
23
  /**
16
24
  * check for media already was uploaded.
@@ -31,6 +39,7 @@ export declare class CMDP_SCHECKUPLOADEDMEDIA_RESPONSE extends CMDP_SCHECKUPLOAD
31
39
  export declare class CMDP_SGETUPLOADEDMEDIA implements ICOMMAND {
32
40
  action: ACTION;
33
41
  params: baseParamsType & MayHaveChannelId & {
42
+ mediaType?: string;
34
43
  skip?: string;
35
44
  limit?: string;
36
45
  };
@@ -42,7 +42,7 @@ export declare class CMDP_SUPLOADMEDIA implements ICOMMAND {
42
42
  params: baseParamsType & MessageParams & UploadServiceReadOnlyParams & MediaOffer;
43
43
  }
44
44
  /**
45
- * Response for CMDP_INIT
45
+ * Response for CMDP_SUPLOADMEDIA
46
46
  */
47
47
  export declare class CMDP_SUPLOADMEDIA_RESPONSE extends CMDP_SUPLOADMEDIA implements IRESPONSE, IBACKENDPAYLOAD {
48
48
  result: RESULT;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "cmd-control-client-lib",
3
3
  "description": "Cmd-Client-Library",
4
- "version": "3.0.42",
4
+ "version": "3.0.45",
5
5
  "directories": {
6
6
  "lib": "./dist"
7
7
  },
@@ -43,75 +43,90 @@ describe("WebSocket connection", () => {
43
43
 
44
44
  CMDConnection._socket.onerror();
45
45
  CMDConnection._socket.onclose();
46
- //First attempt
46
+
47
+ //Zero attempt (immediate reconnect)
47
48
  expect(setTimeout).toHaveBeenCalledTimes(1);
48
- expect(setTimeout).toHaveBeenLastCalledWith(expect.any(Function), 15000);
49
+ expect(setTimeout).toHaveBeenLastCalledWith(expect.any(Function), 0);
49
50
 
50
- const firstError = { reConnectionTimeout: 15000 };
51
+ const firstError = { reConnectionTimeout: 0 };
51
52
  expect(connectionConfig.onError).toHaveBeenCalledWith(firstError);
52
53
  jest.runOnlyPendingTimers();
53
- expect(logger.log).toHaveBeenCalledWith("CMDP. retry connect in 15000 ms");
54
+ expect(logger.log).toHaveBeenCalledWith("CMDP. retry connect in 0 ms");
54
55
  expect(CMDConnection._reConnectAttemptsCount).toEqual(1);
55
56
 
56
- //Second attempt
57
+ //First attempt
57
58
  expect(global.WebSocket).toHaveBeenCalledTimes(2);
58
59
  CMDConnection._socket.onerror();
59
60
  CMDConnection._socket.onclose();
60
61
 
61
- const secondError = { reConnectionTimeout: 30000 };
62
+ const secondError = { reConnectionTimeout: 15000 };
62
63
  expect(setTimeout).toHaveBeenCalledTimes(2);
63
- expect(setTimeout).toHaveBeenLastCalledWith(expect.any(Function), 30000);
64
+ expect(setTimeout).toHaveBeenLastCalledWith(expect.any(Function), 15000);
64
65
  expect(connectionConfig.onError).toHaveBeenCalledWith(secondError);
65
- expect(logger.log).toHaveBeenCalledWith("CMDP. retry connect in 30000 ms");
66
+ expect(logger.log).toHaveBeenCalledWith("CMDP. retry connect in 15000 ms");
66
67
  expect(CMDConnection._reConnectAttemptsCount).toEqual(2);
67
68
 
68
69
  jest.runOnlyPendingTimers();
69
- //Third attempt
70
+ //Second attempt
70
71
  expect(global.WebSocket).toHaveBeenCalledTimes(3);
71
72
  CMDConnection._socket.onerror();
72
73
  CMDConnection._socket.onclose();
73
74
 
74
- const thirdError = { reConnectionTimeout: 45000 };
75
+ const thirdError = { reConnectionTimeout: 30000 };
75
76
  expect(setTimeout).toHaveBeenCalledTimes(3);
76
- expect(setTimeout).toHaveBeenLastCalledWith(expect.any(Function), 45000);
77
+ expect(setTimeout).toHaveBeenLastCalledWith(expect.any(Function), 30000);
77
78
  expect(connectionConfig.onError).toHaveBeenCalledWith(thirdError);
78
- expect(logger.log).toHaveBeenCalledWith("CMDP. retry connect in 45000 ms");
79
+ expect(logger.log).toHaveBeenCalledWith("CMDP. retry connect in 30000 ms");
79
80
  expect(CMDConnection._reConnectAttemptsCount).toEqual(3);
80
81
 
81
82
  jest.runOnlyPendingTimers();
82
- //Fourth attempt
83
+
84
+ //Third attempt
83
85
  expect(global.WebSocket).toHaveBeenCalledTimes(4);
84
86
  CMDConnection._socket.onerror();
85
87
  CMDConnection._socket.onclose();
86
88
 
87
- const fourthError = { reConnectionTimeout: 60000 };
89
+ const fourthError = { reConnectionTimeout: 45000 };
88
90
  expect(setTimeout).toHaveBeenCalledTimes(4);
89
- expect(setTimeout).toHaveBeenLastCalledWith(expect.any(Function), 60000);
91
+ expect(setTimeout).toHaveBeenLastCalledWith(expect.any(Function), 45000);
90
92
  expect(connectionConfig.onError).toHaveBeenCalledWith(fourthError);
91
- expect(logger.log).toHaveBeenCalledWith("CMDP. retry connect in 60000 ms");
93
+ expect(logger.log).toHaveBeenCalledWith("CMDP. retry connect in 45000 ms");
92
94
  expect(CMDConnection._reConnectAttemptsCount).toEqual(4);
93
95
 
94
96
  jest.runOnlyPendingTimers();
95
- //Final attempt
97
+
98
+ //Fourth attempt
96
99
  expect(global.WebSocket).toHaveBeenCalledTimes(5);
97
100
  CMDConnection._socket.onerror();
98
101
  CMDConnection._socket.onclose();
99
102
 
100
- const fifthError = { reConnectionTimeout: 75000 };
103
+ const fifthError = { reConnectionTimeout: 60000 };
101
104
  expect(setTimeout).toHaveBeenCalledTimes(5);
102
- expect(setTimeout).toHaveBeenLastCalledWith(expect.any(Function), 75000);
105
+ expect(setTimeout).toHaveBeenLastCalledWith(expect.any(Function), 60000);
103
106
  expect(connectionConfig.onError).toHaveBeenCalledWith(fifthError);
104
107
  expect(CMDConnection._reConnectAttemptsCount).toEqual(5);
105
108
 
106
109
  jest.runOnlyPendingTimers();
110
+ //Final attempt
107
111
  expect(global.WebSocket).toHaveBeenCalledTimes(6);
108
112
  CMDConnection._socket.onerror();
109
113
  CMDConnection._socket.onclose();
110
114
 
115
+ const finalError = { reConnectionTimeout: 75000 };
116
+ expect(setTimeout).toHaveBeenCalledTimes(6);
117
+ expect(setTimeout).toHaveBeenLastCalledWith(expect.any(Function), 75000);
118
+ expect(connectionConfig.onError).toHaveBeenCalledWith(finalError);
119
+ expect(CMDConnection._reConnectAttemptsCount).toEqual(6);
120
+
121
+ jest.runOnlyPendingTimers();
122
+ expect(global.WebSocket).toHaveBeenCalledTimes(7);
123
+ CMDConnection._socket.onerror();
124
+ CMDConnection._socket.onclose();
125
+
111
126
  const fatalError = { isFatal: true };
112
127
  expect(connectionConfig.onError).toHaveBeenCalledWith(fatalError);
113
128
  //No more setTimeout was called
114
- expect(setTimeout).toHaveBeenCalledTimes(5);
129
+ expect(setTimeout).toHaveBeenCalledTimes(6);
115
130
  expect(logger.log).toHaveBeenCalledWith("CMDP. maximum reconnect attempts count reached");
116
131
  });
117
132
  });