test functionality for server broadcast
authorxangelo <git@xangelo.ca>
Fri, 2 Jun 2023 10:03:13 +0000 (06:03 -0400)
committerxangelo <git@xangelo.ca>
Fri, 2 Jun 2023 10:03:13 +0000 (06:03 -0400)
src/server/api.ts

index 85ba258baec428e18919ec38dbb6f56bea3db8ce..0e4d905b8848a26477320f50e3ea1fcf4678ca16 100644 (file)
@@ -99,7 +99,15 @@ io.on('connection', async socket => {
 
   socket.on('chat', (msg: string) => {
     if(msg.length > 0) {
-      const message = broadcastMessage(player.username, msg);
+
+      let message;
+      if(msg.startsWith('/server lmnop')) {
+        message = broadcastMessage('server', msg.split('/server lmnop ')[1]);
+      }
+      else {
+        message = broadcastMessage(player.username, msg);
+      }
+
       chatHistory.push(message);
       chatHistory.slice(-10);
       io.emit('chat', message);