My NodeJS side project.

So I started dabbling in NodeJS a bit. I’ve been pretty immersed in JavaScript at work and kept bumping up against NodeJS and using websockets and other fun stuffs that most people, even the hardened, long time developers and engineers with PHDs look at in fear like it’s witchcraft….

To be completely honest, I thoroughly understand the design, concepts and code behind NodeJS, socket.io, SockJS, and more, and I will confirm that it is indeed witchcraft.

So, call me Harry Potter, I decided to throw caution to the wind and dive in deep with my first NodeJS side project. At first I didn’t even know what it was going to do I just had an idea in mind and what I came up with was tcp-io-bridge. As of right now it is an early stage of development but I have some working tests. The general concept is a web browser syncs with an actual application using a NodeJS server as the middleman.  The web browser will take advantage of websockets using Socket.IO and the application will use a TCP socket.

The Node app will act as a middleman, connecting the tcp socket to the socket.io client in a 1 to 1 relationship. Actually, this is really optional, we could just run 1 application on the backend and emit globally but that’s for a different project on another day.

The application will send data and commands down the tcp -> ws pipeline to the browser which will be rendered to HTML5 Canvas.. and to be smug I’ve patched in Flash Canvas Pro to support IE8…   oh but wait.. IE8 and IE9 don’t support websockets – well socket.io gracefully falls back to another protocol.. I’ve chosen to abandon flash sockets and the hidden iframe in lieu of XHR…  at this time..  I’m not sure why.. its just a gut decision.

The web browser will send events from the canvas up the ws -> tcp pipeline to the application.  Mousemoves, clicks, keyboard input, canvas resizes, etc..  My eventhandler in itself if some sweet code.. if you’re looking to dump jquery but you need decent cross browser event handling.. check out this one.  BTW, why does Microsoft have to make each release of IE into some additional pain in the ass for web developers?  IE11 doesn’t seem to catch keydown and keyup events on the window or on the canvas, I had to put in a conditional for it specifically for document.

Ok.. long winded post that probably doesn’t make a hell of a lot of sense, attribute to my lack of articulation skills, my bad.  Interesting in peeping the project? Here’s a link on github.

tcp-io-bridge – On GitHub