@flashphoner/websdk 2.0.233 → 2.0.234
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/docTemplate/README.md
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
<script type="text/javascript" src="../../dependencies/bootstrap/js/bootstrap.min.js"></script>
|
|
15
15
|
<script type="text/javascript" src="../../dependencies/js/utils.js"></script>
|
|
16
16
|
<script type="text/javascript" src="../../../../flashphoner-rest-api.js"></script>
|
|
17
|
+
<script type="text/javascript" src="../../../../flashphoner.js"></script>
|
|
17
18
|
<script type="text/javascript" charset="utf8" src="jquery.dataTables.js"></script>
|
|
18
19
|
<script type="text/javascript" src="console.js"></script>
|
|
19
20
|
</head>
|
|
@@ -38,6 +39,7 @@
|
|
|
38
39
|
<th>MEM</th>
|
|
39
40
|
<th>TH</th>
|
|
40
41
|
<th>CONN</th>
|
|
42
|
+
<th>WS</th>
|
|
41
43
|
<th>IN</th>
|
|
42
44
|
<th>OUT</th>
|
|
43
45
|
</tr>
|
|
@@ -49,6 +51,8 @@
|
|
|
49
51
|
<hr>
|
|
50
52
|
<div id="nodeControls" class="row vdivide hidden">
|
|
51
53
|
<div class="col-sm-2">
|
|
54
|
+
<button id="wsSessionsBatchModalBtn" data-toggle='modal' data-target='#wsSessionsBatchModal' type="button" class="btn btn-default btn-success btn-block">Create sessions</button>
|
|
55
|
+
<hr>
|
|
52
56
|
<button id="pullStreamModalBtn" data-toggle='modal' data-target='#pullModal' type="button" class="btn btn-default btn-success btn-block">Pull stream</button>
|
|
53
57
|
<button id="pullRtspStreamModalBtn" data-toggle='modal' data-target='#pullRtspModal' type="button" class="btn btn-default btn-success btn-block">Pull RTSP stream</button>
|
|
54
58
|
<hr>
|
|
@@ -270,6 +274,33 @@
|
|
|
270
274
|
</div>
|
|
271
275
|
</div>
|
|
272
276
|
</div>
|
|
277
|
+
<div id="wsSessionsBatchModal" class="modal fade" role="dialog">
|
|
278
|
+
<div class="modal-dialog">
|
|
279
|
+
<div class="modal-content">
|
|
280
|
+
<div class="modal-header">
|
|
281
|
+
<button type="button" class="close" data-dismiss="modal">×</button>
|
|
282
|
+
<h4>Create sessions to the node</h4>
|
|
283
|
+
</div>
|
|
284
|
+
<div class="modal-body">
|
|
285
|
+
<form action="" id="wsSessionsBatchForm">
|
|
286
|
+
<div class="form-group">
|
|
287
|
+
<label for="wsSessionsBatchNodes"><span class="glyphicon glyphicon-globe"></span> Choose node</label>
|
|
288
|
+
<select class="custom-select" id="wsSessionsBatchNodes">
|
|
289
|
+
</select>
|
|
290
|
+
</div>
|
|
291
|
+
<div class="form-group">
|
|
292
|
+
<label for="wsSessionsBatchQty"><span class="glyphicon glyphicon-plus"></span> Qty</label>
|
|
293
|
+
<input type="text" class="form-control" id="wsSessionsBatchQty" placeholder="1">
|
|
294
|
+
</div>
|
|
295
|
+
<button id="wsSessionsBatchConnect" type="button" class="btn btn-default btn-success btn-block"><span class="glyphicon glyphicon-off"></span> Connect</button>
|
|
296
|
+
</form>
|
|
297
|
+
</div>
|
|
298
|
+
<div class="modal-footer">
|
|
299
|
+
<button type="button" class="btn btn-default pull-left" data-dismiss="modal"><span class="glyphicon glyphicon-remove"></span> Cancel</button>
|
|
300
|
+
</div>
|
|
301
|
+
</div>
|
|
302
|
+
</div>
|
|
303
|
+
</div>
|
|
273
304
|
<div id="registerBatchModal" class="modal fade" role="dialog">
|
|
274
305
|
<div class="modal-dialog">
|
|
275
306
|
<div class="modal-content">
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
const REFRESH_NODE_STATE_INTERVAL = 5000;
|
|
3
|
+
const REFRESH_NODE_STATE_FAILED_INTERVAL = 10000;
|
|
4
|
+
const REFRESH_NODE_DETAILS = 2000;
|
|
5
|
+
const STRESS_TEST_INTERVAL = 1000;
|
|
6
|
+
const STRESS_TEST_FAILED_INTERVAL = STRESS_TEST_INTERVAL * 2;
|
|
7
|
+
const NODE_STATE = {
|
|
8
8
|
NEW: "new",
|
|
9
9
|
ALIVE: "alive",
|
|
10
10
|
ACTIVE: "active",
|
|
11
11
|
DEACTIVATE: "deactivate",
|
|
12
12
|
FAILED: "failed"
|
|
13
13
|
};
|
|
14
|
-
|
|
14
|
+
const NODE_DETAILS_TYPE = {
|
|
15
15
|
ALL: "all",
|
|
16
16
|
PULLED: "pulled",
|
|
17
17
|
RTSP: "rtsp",
|
|
@@ -19,7 +19,7 @@ var NODE_DETAILS_TYPE = {
|
|
|
19
19
|
TESTS: "tests"
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
const STRESS_TESTS = {
|
|
23
23
|
REGISTER: { running: false},
|
|
24
24
|
CALL: { running: false},
|
|
25
25
|
PLAY_STREAM: { running: false},
|
|
@@ -28,7 +28,11 @@ var STRESS_TESTS = {
|
|
|
28
28
|
|
|
29
29
|
var nodes = {};
|
|
30
30
|
|
|
31
|
+
const SESSION_STATUS = Flashphoner.constants.SESSION_STATUS;
|
|
32
|
+
|
|
31
33
|
$(function() {
|
|
34
|
+
Flashphoner.init();
|
|
35
|
+
|
|
32
36
|
$("#addNodeFormSubmit").on("click", function(e){
|
|
33
37
|
var ip = $("#nodeIp").val();
|
|
34
38
|
if (ip && ip.length > 0) {
|
|
@@ -76,6 +80,12 @@ $(function() {
|
|
|
76
80
|
$("#pushBatchStream").on("click", function(e){
|
|
77
81
|
pushStreamBatch();
|
|
78
82
|
});
|
|
83
|
+
$('#wsSessionsBatchModal').on('show.bs.modal', function(e) {
|
|
84
|
+
populateNodes($("#wsSessionsBatchNodes"));
|
|
85
|
+
});
|
|
86
|
+
$("#wsSessionsBatchConnect").on("click", function(e){
|
|
87
|
+
wsSessionsBatch();
|
|
88
|
+
});
|
|
79
89
|
$('#registerBatchModal').on('show.bs.modal', function(e) {
|
|
80
90
|
populateNodes($("#registerBatchNodes"));
|
|
81
91
|
});
|
|
@@ -163,6 +173,7 @@ function createNode(id, ip) {
|
|
|
163
173
|
api.ip = nodeIp;
|
|
164
174
|
api.port = port;
|
|
165
175
|
api.tests = [];
|
|
176
|
+
api.wsSessions = {};
|
|
166
177
|
let state = NODE_STATE.NEW;
|
|
167
178
|
let pollState = function(){
|
|
168
179
|
api.stat.poll().then(function(stat){
|
|
@@ -280,6 +291,17 @@ function createNode(id, ip) {
|
|
|
280
291
|
const json = await result.json();
|
|
281
292
|
return json;
|
|
282
293
|
}
|
|
294
|
+
api.createWsSession = function(wsUrl) {
|
|
295
|
+
Flashphoner.createSession({urlServer: wsUrl}).on(SESSION_STATUS.ESTABLISHED, function (session) {
|
|
296
|
+
api.wsSessions[session.id()] = session;
|
|
297
|
+
}).on(SESSION_STATUS.DISCONNECTED, function (session) {
|
|
298
|
+
console.log("Session with " + wsUrl + " (id: " + session.id() + ") disconnected");
|
|
299
|
+
delete api.wsSessions[session.id()];
|
|
300
|
+
}).on(SESSION_STATUS.FAILED, function (session) {
|
|
301
|
+
console.log("Session with " + wsUrl + " (id: " + session.id() + ") failed");
|
|
302
|
+
delete api.wsSessions[session.id()];
|
|
303
|
+
});
|
|
304
|
+
}
|
|
283
305
|
return api;
|
|
284
306
|
}
|
|
285
307
|
|
|
@@ -329,6 +351,7 @@ function updateNodeState(id, state) {
|
|
|
329
351
|
"<td id='"+id+"-state-mem'>"+(mem)+"</td>" +
|
|
330
352
|
"<td id='"+id+"-state-threads'>"+state.core.core_threads+"</td>" +
|
|
331
353
|
"<td id='"+id+"-state-conn'>"+state.connection.connections+"</td>" +
|
|
354
|
+
"<td id='"+id+"-state-ws'>"+state.connection.connections_websocket+"</td>" +
|
|
332
355
|
"<td id='"+id+"-state-in'>"+(streamsIn)+"</td>" +
|
|
333
356
|
"<td id='"+id+"-state-out'>"+(streamsOut)+"</td>" +
|
|
334
357
|
"</tr>";
|
|
@@ -339,6 +362,7 @@ function updateNodeState(id, state) {
|
|
|
339
362
|
$("#"+id+"-state-mem").text(mem);
|
|
340
363
|
$("#"+id+"-state-threads").text(state.core.core_threads);
|
|
341
364
|
$("#"+id+"-state-conn").text(state.connection.connections);
|
|
365
|
+
$("#"+id+"-state-ws").text(state.connection.connections_websocket);
|
|
342
366
|
$("#"+id+"-state-in").text(streamsIn);
|
|
343
367
|
$("#"+id+"-state-out").text(streamsOut);
|
|
344
368
|
}
|
|
@@ -462,6 +486,25 @@ function pullRTSPStream() {
|
|
|
462
486
|
$("#pullRtspModal").modal('hide');
|
|
463
487
|
}
|
|
464
488
|
|
|
489
|
+
function wsSessionsBatch() {
|
|
490
|
+
if (!$("#wsSessionsBatchNodes").val()) {
|
|
491
|
+
$('#warningModal').modal();
|
|
492
|
+
return false;
|
|
493
|
+
}
|
|
494
|
+
var node = getActiveNode();
|
|
495
|
+
var remote = getWebsocketUrl($("#wsSessionsBatchNodes").val()) + "/";
|
|
496
|
+
var qty = parseInt($("#wsSessionsBatchQty").val());
|
|
497
|
+
var interval = setInterval(function(){
|
|
498
|
+
if (qty > 0) {
|
|
499
|
+
node.createWsSession(remote);
|
|
500
|
+
qty--;
|
|
501
|
+
} else {
|
|
502
|
+
clearInterval(interval);
|
|
503
|
+
}
|
|
504
|
+
}, 200);
|
|
505
|
+
$("#wsSessionsBatchModal").modal('hide');
|
|
506
|
+
}
|
|
507
|
+
|
|
465
508
|
//pullBatchStream
|
|
466
509
|
|
|
467
510
|
function pullStreamBatch() {
|