Messages from io gets saved to redis in message list. Endpoint for clearing, should be called when a lottery is ended.

This commit is contained in:
2020-03-17 01:05:26 +01:00
parent c893d7d870
commit cda945ead8
3 changed files with 42 additions and 1 deletions

View File

@@ -1,4 +1,7 @@
module.exports = io => {
const path = require("path");
const { addMessage } = require(path.join(__dirname + "/redis.js"));
const io = (io) => {
io.on("connection", socket => {
let username = null;
@@ -19,7 +22,10 @@ module.exports = io => {
socket.on("chat", msg => {
msg.username = username;
msg.timestamp = new Date().getTime();
addMessage(msg);
io.emit("chat", msg);
});
});
};
module.exports = io;