Skip to content

Commit 13ee254

Browse files
Switcher: Remove unused code
1 parent a9a3f18 commit 13ee254

1 file changed

Lines changed: 2 additions & 8 deletions

File tree

Server/src/Switcher.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ let FlowTable = new Map<String, String[]>([
2424
["R3", ["R2", "E2", "", "", "", ""]],
2525
]);
2626

27-
let receivingClient = { ip: "", port: 0 };
2827

2928
/** Receive Messages from Routers */
3029
let routerCount: number = 0, clientCount: number = 0;
@@ -45,18 +44,13 @@ Switcher.on('message', (msg, rinfo) => {
4544
// Type 1: New Router broadcasting existence
4645
console.log("New Router detected");
4746

48-
// if(++routerCount == 1) {
49-
// TODO: If this is the first Router, send the IP and Port to the Client ? Possible option
50-
// }
51-
52-
5347
// Assign ID to Router and add to Router List
5448
routerId = `R${++routerCount}`;
5549
Routers.add(newClient({ address, port, routerId }));
5650
sendMessage = { routerId, message: "New Router", address, port };
5751
messageType = 0;
5852
break;
59-
53+
6054
case 2:
6155
// Type 2: Current Router querying for information about Clients from Forwarding Table
6256
console.log("Router querying for Clients");
@@ -100,7 +94,6 @@ Switcher.on('message', (msg, rinfo) => {
10094
// Send message to Client
10195
let message = prepareMessage(messageType, { origin: "switcher", serverTime: new Date(), message: sendMessage });
10296
sendMessageToRouter(message, address, port);
103-
10497
});
10598

10699
// Send message to Router
@@ -153,6 +146,7 @@ function broadcast(broadcastMessage: string) {
153146

154147
/** Launch UDP Socket and HTTP Servers, and listen on given port */
155148
try {
149+
Switcher.on('listening', (): void => {
156150
const address = Switcher.address();
157151
console.log(`Switcher Server listening ${address.address}:${address.port}`);
158152
});

0 commit comments

Comments
 (0)