Submit templates for repl.it/templates here.

← Back to all posts
(Template Jam) Socket.io Chat Template
h
lynnlo (51)

Here's a chat client I made for the template jam.

It uses a express server and socket.io for the server side and socket.io client for the client side.

It's very basic and minimal but it does have some features to prevent spamming and also has a custom message sound I made (Which can be easily replaced). The chat also supports chat rooms which can be easily turned off given you know a little bit about socket.io.

Of course this is meant to be a template so everything is made to just work and designs or features that would obstruct the ease of adaptability of the template was not pursued. I did not comment on my code because I think it's decently readable but if enough people thinks that would benefit the end users then I could do it.

Please feel free to try it out invite some friends to test it out.

If you have suggests or comments please comment below.

Comments
hotnewtop
sovereigndawn (0)

how do you make a log for this?

lynnlo (51)

@sovereigndawn You can append message, user, and time on a text file using the fs library on the send event.

AmazingMech2418 (1082)

One thing I would recommend is to use just a plain HTTP server. Express and Socket.io each take up a lot of storage and, while Socket.io is needed (at least I think... I'm not sure what other websockets you can use), express isn't. Instead of using the express.static, you can simply read the paths of URLs and send files through the fs module corresponding to the URLs. Also, if you want to take it a step further, you could add a database system and add end-to-end encryption (I'd recommend Diffie-Hellman rather than RSA because it is easier and faster in browser JS)... Anyways, great job!