Suppose I am doing a websocket server chat (node.js + socket.io). How can I store chat messages, so that when a βnewβ user joins a chat, he will see old chat messages, not just those that were sent while he was in the chat.
Should data be stored in variables on the server? Sort of:
var io = require('socket.io').listen(80); var saveData = { }; io.sockets.on('connection', function (socket) { socket.emit('news', { hello: 'world' }); socket.on('my other event', function (data) { console.log(data); }); });
Will it be a viable embodiment for a more complex application, for example, for a game?
thanks
Johan source share