cmd-control-client-lib 3.0.43 → 3.0.46
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.
package/dist/protocol/media.d.ts
CHANGED
|
@@ -5,20 +5,29 @@ 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 &
|
|
19
|
+
params: MediaFile & MayHaveChannelId & {
|
|
20
|
+
linkState?: ChannelMediaLinkState;
|
|
21
|
+
};
|
|
14
22
|
}
|
|
15
23
|
/**
|
|
16
24
|
* check for media already was uploaded.
|
|
17
25
|
* mediaMd5 - comaseparated media md5
|
|
26
|
+
* channelId - comaseparated channelId
|
|
18
27
|
*/
|
|
19
28
|
export declare class CMDP_SCHECKUPLOADEDMEDIA implements ICOMMAND {
|
|
20
29
|
action: ACTION;
|
|
21
|
-
params: baseParamsType & MediaMd5;
|
|
30
|
+
params: baseParamsType & MediaMd5 & MayHaveChannelId;
|
|
22
31
|
}
|
|
23
32
|
/**
|
|
24
33
|
* media infos, if any found in cache
|
|
@@ -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
|
|
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
|
@@ -43,75 +43,90 @@ describe("WebSocket connection", () => {
|
|
|
43
43
|
|
|
44
44
|
CMDConnection._socket.onerror();
|
|
45
45
|
CMDConnection._socket.onclose();
|
|
46
|
-
|
|
46
|
+
|
|
47
|
+
//Zero attempt (immediate reconnect)
|
|
47
48
|
expect(setTimeout).toHaveBeenCalledTimes(1);
|
|
48
|
-
expect(setTimeout).toHaveBeenLastCalledWith(expect.any(Function),
|
|
49
|
+
expect(setTimeout).toHaveBeenLastCalledWith(expect.any(Function), 0);
|
|
49
50
|
|
|
50
|
-
const firstError = { reConnectionTimeout:
|
|
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
|
|
54
|
+
expect(logger.log).toHaveBeenCalledWith("CMDP. retry connect in 0 ms");
|
|
54
55
|
expect(CMDConnection._reConnectAttemptsCount).toEqual(1);
|
|
55
56
|
|
|
56
|
-
//
|
|
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:
|
|
62
|
+
const secondError = { reConnectionTimeout: 15000 };
|
|
62
63
|
expect(setTimeout).toHaveBeenCalledTimes(2);
|
|
63
|
-
expect(setTimeout).toHaveBeenLastCalledWith(expect.any(Function),
|
|
64
|
+
expect(setTimeout).toHaveBeenLastCalledWith(expect.any(Function), 15000);
|
|
64
65
|
expect(connectionConfig.onError).toHaveBeenCalledWith(secondError);
|
|
65
|
-
expect(logger.log).toHaveBeenCalledWith("CMDP. retry connect in
|
|
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
|
-
//
|
|
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:
|
|
75
|
+
const thirdError = { reConnectionTimeout: 30000 };
|
|
75
76
|
expect(setTimeout).toHaveBeenCalledTimes(3);
|
|
76
|
-
expect(setTimeout).toHaveBeenLastCalledWith(expect.any(Function),
|
|
77
|
+
expect(setTimeout).toHaveBeenLastCalledWith(expect.any(Function), 30000);
|
|
77
78
|
expect(connectionConfig.onError).toHaveBeenCalledWith(thirdError);
|
|
78
|
-
expect(logger.log).toHaveBeenCalledWith("CMDP. retry connect in
|
|
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
|
-
|
|
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:
|
|
89
|
+
const fourthError = { reConnectionTimeout: 45000 };
|
|
88
90
|
expect(setTimeout).toHaveBeenCalledTimes(4);
|
|
89
|
-
expect(setTimeout).toHaveBeenLastCalledWith(expect.any(Function),
|
|
91
|
+
expect(setTimeout).toHaveBeenLastCalledWith(expect.any(Function), 45000);
|
|
90
92
|
expect(connectionConfig.onError).toHaveBeenCalledWith(fourthError);
|
|
91
|
-
expect(logger.log).toHaveBeenCalledWith("CMDP. retry connect in
|
|
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
|
-
|
|
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:
|
|
103
|
+
const fifthError = { reConnectionTimeout: 60000 };
|
|
101
104
|
expect(setTimeout).toHaveBeenCalledTimes(5);
|
|
102
|
-
expect(setTimeout).toHaveBeenLastCalledWith(expect.any(Function),
|
|
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(
|
|
129
|
+
expect(setTimeout).toHaveBeenCalledTimes(6);
|
|
115
130
|
expect(logger.log).toHaveBeenCalledWith("CMDP. maximum reconnect attempts count reached");
|
|
116
131
|
});
|
|
117
132
|
});
|