Revert "Improving log messages"
This commit is contained in:
parent
6c5f330b71
commit
6e6cdc7bde
38 changed files with 203 additions and 581 deletions
|
@ -31,7 +31,6 @@ import { User, UserSocket } from "./Model/User";
|
|||
import { GameRoom } from "./Model/GameRoom";
|
||||
import Debug from "debug";
|
||||
import { Admin } from "./Model/Admin";
|
||||
import log from "./Services/Logger";
|
||||
|
||||
const debug = Debug("roommanager");
|
||||
|
||||
|
@ -41,7 +40,7 @@ export type RoomSocket = ServerWritableStream<RoomMessage, BatchToPusherRoomMess
|
|||
|
||||
const roomManager: IRoomManagerServer = {
|
||||
joinRoom: (call: UserSocket): void => {
|
||||
log.info("joinRoom called");
|
||||
console.log("joinRoom called");
|
||||
|
||||
let room: GameRoom | null = null;
|
||||
let user: User | null = null;
|
||||
|
@ -132,11 +131,11 @@ const roomManager: IRoomManagerServer = {
|
|||
}
|
||||
}
|
||||
} catch (e) {
|
||||
log.error(e);
|
||||
console.error(e);
|
||||
emitError(call, e);
|
||||
call.end();
|
||||
}
|
||||
})().catch((e) => log.error(e));
|
||||
})().catch((e) => console.error(e));
|
||||
});
|
||||
|
||||
call.on("end", () => {
|
||||
|
@ -150,7 +149,7 @@ const roomManager: IRoomManagerServer = {
|
|||
});
|
||||
|
||||
call.on("error", (err: Error) => {
|
||||
log.error("An error occurred in joinRoom stream:", err);
|
||||
console.error("An error occurred in joinRoom stream:", err);
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -168,7 +167,7 @@ const roomManager: IRoomManagerServer = {
|
|||
debug("listenZone cancelled");
|
||||
socketManager
|
||||
.removeZoneListener(call, zoneMessage.getRoomid(), zoneMessage.getX(), zoneMessage.getY())
|
||||
.catch((e) => log.error(e));
|
||||
.catch((e) => console.error(e));
|
||||
call.end();
|
||||
});
|
||||
|
||||
|
@ -176,12 +175,12 @@ const roomManager: IRoomManagerServer = {
|
|||
debug("listenZone connection closed");
|
||||
socketManager
|
||||
.removeZoneListener(call, zoneMessage.getRoomid(), zoneMessage.getX(), zoneMessage.getY())
|
||||
.catch((e) => log.error(e));
|
||||
.catch((e) => console.error(e));
|
||||
}).on("error", (e) => {
|
||||
log.error("An error occurred in listenZone stream:", e);
|
||||
console.error("An error occurred in listenZone stream:", e);
|
||||
socketManager
|
||||
.removeZoneListener(call, zoneMessage.getRoomid(), zoneMessage.getX(), zoneMessage.getY())
|
||||
.catch((e) => log.error(e));
|
||||
.catch((e) => console.error(e));
|
||||
call.end();
|
||||
});
|
||||
},
|
||||
|
@ -196,22 +195,22 @@ const roomManager: IRoomManagerServer = {
|
|||
|
||||
call.on("cancelled", () => {
|
||||
debug("listenRoom cancelled");
|
||||
socketManager.removeRoomListener(call, roomMessage.getRoomid()).catch((e) => log.error(e));
|
||||
socketManager.removeRoomListener(call, roomMessage.getRoomid()).catch((e) => console.error(e));
|
||||
call.end();
|
||||
});
|
||||
|
||||
call.on("close", () => {
|
||||
debug("listenRoom connection closed");
|
||||
socketManager.removeRoomListener(call, roomMessage.getRoomid()).catch((e) => log.error(e));
|
||||
socketManager.removeRoomListener(call, roomMessage.getRoomid()).catch((e) => console.error(e));
|
||||
}).on("error", (e) => {
|
||||
log.error("An error occurred in listenRoom stream:", e);
|
||||
socketManager.removeRoomListener(call, roomMessage.getRoomid()).catch((e) => log.error(e));
|
||||
console.error("An error occurred in listenRoom stream:", e);
|
||||
socketManager.removeRoomListener(call, roomMessage.getRoomid()).catch((e) => console.error(e));
|
||||
call.end();
|
||||
});
|
||||
},
|
||||
|
||||
adminRoom(call: AdminSocket): void {
|
||||
log.info("adminRoom called");
|
||||
console.log("adminRoom called");
|
||||
|
||||
const admin = new Admin(call);
|
||||
let room: GameRoom | null = null;
|
||||
|
@ -226,7 +225,7 @@ const roomManager: IRoomManagerServer = {
|
|||
.then((gameRoom: GameRoom) => {
|
||||
room = gameRoom;
|
||||
})
|
||||
.catch((e) => log.error(e));
|
||||
.catch((e) => console.error(e));
|
||||
} else {
|
||||
throw new Error("The first message sent MUST be of type JoinRoomMessage");
|
||||
}
|
||||
|
@ -247,13 +246,13 @@ const roomManager: IRoomManagerServer = {
|
|||
});
|
||||
|
||||
call.on("error", (err: Error) => {
|
||||
log.error("An error occurred in joinAdminRoom stream:", err);
|
||||
console.error("An error occurred in joinAdminRoom stream:", err);
|
||||
});
|
||||
},
|
||||
sendAdminMessage(call: ServerUnaryCall<AdminMessage>, callback: sendUnaryData<EmptyMessage>): void {
|
||||
socketManager
|
||||
.sendAdminMessage(call.request.getRoomid(), call.request.getRecipientuuid(), call.request.getMessage())
|
||||
.catch((e) => log.error(e));
|
||||
.catch((e) => console.error(e));
|
||||
|
||||
callback(null, new EmptyMessage());
|
||||
},
|
||||
|
@ -266,7 +265,7 @@ const roomManager: IRoomManagerServer = {
|
|||
// FIXME Work in progress
|
||||
socketManager
|
||||
.banUser(call.request.getRoomid(), call.request.getRecipientuuid(), call.request.getMessage())
|
||||
.catch((e) => log.error(e));
|
||||
.catch((e) => console.error(e));
|
||||
|
||||
callback(null, new EmptyMessage());
|
||||
},
|
||||
|
@ -274,7 +273,7 @@ const roomManager: IRoomManagerServer = {
|
|||
// FIXME: we could improve return message by returning a Success|ErrorMessage message
|
||||
socketManager
|
||||
.sendAdminRoomMessage(call.request.getRoomid(), call.request.getMessage(), call.request.getType())
|
||||
.catch((e) => log.error(e));
|
||||
.catch((e) => console.error(e));
|
||||
callback(null, new EmptyMessage());
|
||||
},
|
||||
sendWorldFullWarningToRoom(
|
||||
|
@ -282,7 +281,7 @@ const roomManager: IRoomManagerServer = {
|
|||
callback: sendUnaryData<EmptyMessage>
|
||||
): void {
|
||||
// FIXME: we could improve return message by returning a Success|ErrorMessage message
|
||||
socketManager.dispatchWorldFullWarning(call.request.getRoomid()).catch((e) => log.error(e));
|
||||
socketManager.dispatchWorldFullWarning(call.request.getRoomid()).catch((e) => console.error(e));
|
||||
callback(null, new EmptyMessage());
|
||||
},
|
||||
sendRefreshRoomPrompt(
|
||||
|
@ -290,7 +289,7 @@ const roomManager: IRoomManagerServer = {
|
|||
callback: sendUnaryData<EmptyMessage>
|
||||
): void {
|
||||
// FIXME: we could improve return message by returning a Success|ErrorMessage message
|
||||
socketManager.dispatchRoomRefresh(call.request.getRoomid()).catch((e) => log.error(e));
|
||||
socketManager.dispatchRoomRefresh(call.request.getRoomid()).catch((e) => console.error(e));
|
||||
callback(null, new EmptyMessage());
|
||||
},
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue