From: xangelo Date: Fri, 2 Jun 2023 10:03:13 +0000 (-0400) Subject: test functionality for server broadcast X-Git-Tag: v0.0.1~78 X-Git-Url: https://git.xangelo.ca/?a=commitdiff_plain;h=328e419d9a1755d255552cd74b6ad8f805814916;p=risinglegends.git test functionality for server broadcast --- diff --git a/src/server/api.ts b/src/server/api.ts index 85ba258..0e4d905 100644 --- a/src/server/api.ts +++ b/src/server/api.ts @@ -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);