From 1bbd0866cb247cf474355b63787ca0f8c7f58207 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20N=C3=A9grier?= Date: Sat, 16 May 2020 16:07:38 +0200 Subject: [PATCH] Code cleaning --- back/src/Controller/IoSocketController.ts | 10 ++++++---- back/tsconfig.json | 2 +- front/src/WebRtc/SimplePeer.ts | 17 +++-------------- 3 files changed, 10 insertions(+), 19 deletions(-) diff --git a/back/src/Controller/IoSocketController.ts b/back/src/Controller/IoSocketController.ts index 9ea8899..2c79879 100644 --- a/back/src/Controller/IoSocketController.ts +++ b/back/src/Controller/IoSocketController.ts @@ -94,10 +94,11 @@ export class IoSocketController { x: user x position on map y: user y position on map */ - socket.on(SockerIoEvent.JOIN_ROOM, (roomId: any) => { + socket.on(SockerIoEvent.JOIN_ROOM, (roomId: any): void => { try { if (typeof(roomId) !== 'string') { - return socket.emit(SockerIoEvent.MESSAGE_ERROR, {message: 'Expected roomId as a string.'}) + socket.emit(SockerIoEvent.MESSAGE_ERROR, {message: 'Expected roomId as a string.'}); + return; } let Client = (socket as ExSocketInterface); @@ -124,11 +125,12 @@ export class IoSocketController { } }); - socket.on(SockerIoEvent.USER_POSITION, (message: any) => { + socket.on(SockerIoEvent.USER_POSITION, (message: any): void => { try { let position = this.hydratePositionReceive(message); if (position instanceof Error) { - return socket.emit(SockerIoEvent.MESSAGE_ERROR, {message: position.message}); + socket.emit(SockerIoEvent.MESSAGE_ERROR, {message: position.message}); + return; } let Client = (socket as ExSocketInterface); diff --git a/back/tsconfig.json b/back/tsconfig.json index 7686fb6..03f8c9d 100644 --- a/back/tsconfig.json +++ b/back/tsconfig.json @@ -36,7 +36,7 @@ /* Additional Checks */ // "noUnusedLocals": true, /* Report errors on unused locals. */ // "noUnusedParameters": true, /* Report errors on unused parameters. */ - // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ + "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ /* Module Resolution Options */ diff --git a/front/src/WebRtc/SimplePeer.ts b/front/src/WebRtc/SimplePeer.ts index 54b7e0e..595e83b 100644 --- a/front/src/WebRtc/SimplePeer.ts +++ b/front/src/WebRtc/SimplePeer.ts @@ -49,18 +49,12 @@ export class SimplePeer implements SimplePeerInterface{ }); //receive signal by gemer - this.Connexion.disconnectMessage((message: any) => { - let data = message; + this.Connexion.disconnectMessage((data: any) => { this.closeConnexion(data.userId); }); } - /** - * - * @param message - */ - private receiveWebrtcStart(message: any) { - let data = message; + private receiveWebrtcStart(data: any) { this.WebRtcRoomId = data.roomId; this.Users = data.clients; @@ -193,12 +187,7 @@ export class SimplePeer implements SimplePeerInterface{ } } - /** - * - * @param message - */ - private receiveWebrtcSignal(message: any) { - let data = message; + private receiveWebrtcSignal(data: any) { try { //if offer type, create peer connexion if(data.signal.type === "offer"){ -- 2.25.1