Switching to Websockets and Cleaning Up

Today we worked on completing the switch from using AJAX to websockets for all of the code in our back end and browser hook that logs the information. This was a slow and steady process of editing both ends to slowly get us moved over. We test as we go using both unit tests and a little HTML page with inline JavaScript to play with it and see how the new method gets the data into the database.

The funny thing is we noticed as we did this that we don’t even need Express.js anymore at this point. We do need a simple HTTP server running just to interface with Amazon Web Services, and for performing a few development administrative tasks (like manually clearing the database and creating tables), but the actual work is done with just websockets. So we refactored our back end by removing Express.js and replacing it with just the websocket server code, using that “ws” Node.js library. Less is more is our opinion. I joked that I like removing code more than I like making code, and I think that philosophy holds merit.

Our next steps are to identify any other information we want to log last minute before we send this prototype off to Engineering.com, and also to investigate using encryption (using WebSocket Secure aka wss:// instead of WebSocket aka ws://) to make our app more robust once it hits production.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s