Skip to content

Commit 2e0ea74

Browse files
committed
Format text
1 parent 4aa3647 commit 2e0ea74

1 file changed

Lines changed: 33 additions & 48 deletions

File tree

README.md

Lines changed: 33 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -330,32 +330,32 @@ var wss = new ws.Server({
330330
path: "/helloworld"
331331
});
332332
333-
wss.on("connection", function(ws) {
333+
wss.on("connection", function (ws) {
334334
var sessionId = null;
335335
var request = ws.upgradeReq;
336336
var response = {
337337
writeHead: {}
338338
};
339339
340-
sessionHandler(request, response, function(err) {
340+
sessionHandler(request, response, function (err) {
341341
sessionId = request.session.id;
342342
});
343343
344-
ws.on("error", error => {
344+
ws.on("error", (error) => {
345345
stop(sessionId);
346346
});
347347
348348
ws.on("close", () => {
349349
stop(sessionId);
350350
});
351351
352-
ws.on("message", _message => {
352+
ws.on("message", (_message) => {
353353
var message = JSON.parse(_message);
354354
355355
switch (message.id) {
356356
case "start":
357357
sessionId = request.session.id;
358-
start(sessionId, ws, message.sdpOffer, function(error, sdpAnswer) {
358+
start(sessionId, ws, message.sdpOffer, function (error, sdpAnswer) {
359359
ws.send(
360360
JSON.stringify({
361361
id: "startResponse",
@@ -434,8 +434,8 @@ function start(sessionId, ws, sdpOffer, callback) {
434434
}
435435
}
436436
// Connect it back on itself (i.e. in loopback)
437-
connectMediaElements(webRtcEndpoint, error => {
438-
webRtcEndpoint.on("OnIceCandidate", function(event) {
437+
connectMediaElements(webRtcEndpoint, (error) => {
438+
webRtcEndpoint.on("OnIceCandidate", function (event) {
439439
const candidate = kurento.getComplexType("IceCandidate")(event.candidate);
440440
ws.send(
441441
JSON.stringify({
@@ -453,7 +453,7 @@ function start(sessionId, ws, sdpOffer, callback) {
453453
return callback(null, sdpAnswer);
454454
});
455455
456-
webRtcEndpoint.gatherCandidates(error => {
456+
webRtcEndpoint.gatherCandidates((error) => {
457457
if (error) {
458458
return callback(error);
459459
}
@@ -480,15 +480,12 @@ function createMediaElements(pipeline, ws, callback) {
480480

481481
```javascript
482482
function connectMediaElements(webRtcEndpoint, callback) {
483-
webRtcEndpoint.connect(
484-
webRtcEndpoint,
485-
error => {
486-
if (error) {
487-
return callback(error);
488-
}
489-
return callback(null);
483+
webRtcEndpoint.connect(webRtcEndpoint, (error) => {
484+
if (error) {
485+
return callback(error);
490486
}
491-
);
487+
return callback(null);
488+
});
492489
}
493490
```
494491

@@ -538,7 +535,7 @@ function start() {
538535
onicecandidate: onIceCandidate
539536
};
540537
541-
webRtcPeer = kurentoUtils.WebRtcPeer.WebRtcPeerSendrecv(options, function(error) {
538+
webRtcPeer = kurentoUtils.WebRtcPeer.WebRtcPeerSendrecv(options, function (error) {
542539
if (error) return onError(error);
543540
this.generateOffer(onOffer);
544541
});
@@ -563,7 +560,7 @@ Whenever a WebSocket message is received, either starting communication, changin
563560
an appropriate action is taken.
564561

565562
```javascript
566-
ws.onmessage = function(message) {
563+
ws.onmessage = function (message) {
567564
var parsedMessage = JSON.parse(message.data);
568565
569566
switch (parsedMessage.id) {
@@ -654,7 +651,7 @@ function createMediaElements(pipeline, ws, callback) {
654651
-1.2,
655652
1.6,
656653
1.6,
657-
function(error) {
654+
function (error) {
658655
if (error) {
659656
return callback(error);
660657
}
@@ -668,24 +665,18 @@ function createMediaElements(pipeline, ws, callback) {
668665

669666
```javascript
670667
function connectMediaElements(webRtcEndpoint, faceOverlayFilter, callback) {
671-
webRtcEndpoint.connect(
672-
faceOverlayFilter,
673-
error => {
668+
webRtcEndpoint.connect(faceOverlayFilter, (error) => {
669+
if (error) {
670+
return callback(error);
671+
}
672+
faceOverlayFilter.connect(webRtcEndpoint, (error) => {
674673
if (error) {
675674
return callback(error);
676675
}
677-
faceOverlayFilter.connect(
678-
webRtcEndpoint,
679-
error => {
680-
if (error) {
681-
return callback(error);
682-
}
683676
684-
return callback(null);
685-
}
686-
);
687-
}
688-
);
677+
return callback(null);
678+
});
679+
});
689680
}
690681
```
691682

@@ -816,25 +807,19 @@ function createMediaElements(pipeline, ws, callback) {
816807

817808
```javascript
818809
function connectMediaElements(webRtcEndpoint, filter, callback) {
819-
webRtcEndpoint.connect(
820-
filter,
821-
error => {
810+
webRtcEndpoint.connect(filter, (error) => {
811+
if (error) {
812+
return callback(error);
813+
}
814+
815+
filter.connect(webRtcEndpoint, (error) => {
822816
if (error) {
823817
return callback(error);
824818
}
825819

826-
filter.connect(
827-
webRtcEndpoint,
828-
error => {
829-
if (error) {
830-
return callback(error);
831-
}
832-
833-
return callback(null);
834-
}
835-
);
836-
}
837-
);
820+
return callback(null);
821+
});
822+
});
838823
}
839824
```
840825

0 commit comments

Comments
 (0)