Skip to content

Commit 1cfb155

Browse files
Manage Client instructions
1 parent a861663 commit 1cfb155

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Server/src/Router.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,13 @@ Router.on('message', (msg, senderInfo) => {
5757
// Type 5: Message from Client - received message instructions from Client to send message over the network
5858
console.log("Client has sent message instructions");
5959

60-
// Request information about Clients from Switcher
61-
connectToSwitcher();
60+
if (currentRouter.routerId && currentRouter.forwardAddress && currentRouter.forwardPort) {
61+
// Forward message to next Router or Client
62+
forwardMessage(prepareMessage(5, receivedMessage), currentRouter.forwardAddress, currentRouter.forwardPort);
63+
} else {
64+
// Request information about Clients from Switcher
65+
connectToSwitcher();
66+
}
6267
break;
6368
case 6:
6469
// Type 6: Message from Switcher - updated information about this Router received

0 commit comments

Comments
 (0)