Awesome FOSS Logo
Discover awesome open source software
Launched 🚀🧑‍🚀

First Foray into web chat

Categories

Recently, I’ve been doing a lot of web stuff. “A lot” is an understatement, as I think about it, I’ve been working exclusively on projects that have to do with the web, or in some way are connected to HTML/CSS/JS/Some web framework.

Though I know web programmers don’t get as much “rep” as other kinds that are writing compilers maybe, I think the instant utility (as well as gratification) of web apps is something not easily overlooked.

Not necessarily looking to solve world hunger, I ventured to try and make a web chat client for people to chat anonymously on. I’m trying to initially target actually the Japanese sector of the internet, see if they are interested in chatting, on any topic, at any time, anywhere. Technically, the task is very simple (and a bunch of web/other frameworks even have this sort of task as the introductory guide) — but implementing it was very fun.

As I understand it, there are basically two approaches to implementing chat systems on the web:

  1. Polling (Whether long, or my naive short implementation)

  2. Managed Connections

So my naive implementation was just to poll the server every 3 seconds or so to see if there were any new messages for the user. of course, with a hundred concurrent users, this will create enormous strain on the servers, but I wanted to just get something working so that I could test the interface and demo it a little.

Long polling is the traditional implementation, and that involves setting up connections to the webserver, but having the web server DELAY responses, until new messages come in. If messages arrive with 3 second frequency (like I set in my naive implementation) — then my implementation and long polling might be no different, but that’s obvious a moot case.

  1. Managed connections are dealing with things like web sockets and the lesser known alternatives (there are some w3c standards for streaming updates to clients) – these methods open up a uni or bidirectional connection to the server, and follow pub/sub semantics.

All the boring chat stuff aside — I did have an absolute blast working with knockoutJS. It is a wonderful (light) library for adding amazing functionality to your site. One of the major features is declarative data bindings and effectively DOM management, which is amazing. Though there are many alternatives (Ember, Angular,Backbone), I found that knockout was super light, didn’t force me to make too many overbearing design desicions, and was just what I needed.

The project (still a WIP) is @