N
N
nepster-web2014-01-12 14:12:25
Node.js
nepster-web, 2014-01-12 14:12:25

How to implement a simple chat for the game?

Actually we are writing a game portal and there is a task to attach a chat to each game.

We use for the game: node.js + socket.io

I would like to know some tips, maybe someone found a simple chat on node.js.
All that is required is the ability to send messages to rooms, anti-mat, anti-spam filters and protection against injections and other hacking.

Actually, there are millions of implementations of such chats, but not everyone falls under the item "protection against injections and other hacking".

Therefore, if someone has used such reliable but simple chats, please advise options.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Y
Yaroslav, 2014-01-12
@nepster-web

On node.js + socket.io, it takes 2 days to implement a simple chat. Moreover, most of the time will be spent on the client: design, layout, emoticons, nickname highlighting, user information, sounds, and so on.
About the rooms. In socket.io they are already implemented .
About security. The chat server is essentially an echo server. It simply forwards messages from the client to the clients. He does not need to know the content of the messages. Therefore, for security, in most cases, it is enough to authorize on the server and clean up the incoming data on the client with a simple function:

function htmlEscape(text) {
   return text.replace(/&/g, '&').
     replace(/</g, '&lt;'). 
     replace(/"/g, '&quot;').
     replace(/'/g, '&#039;');
}

You can see a simple chat implementation here .

S
Sergey, 2014-01-12
Protko @Fesor

stackoverflow.com/questions/17225697/secure-node-j...
stackoverflow.com/questions/3705356/preventing-xss...
so that's your concern...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question