I wonder how this thing works

This is learning diary post from Uni Helsinki course Software Factory / Facebook academy – SocketIO team. For more info about this course read  “Ready, Set, Start Coding!”.

You can find open issues and questions I collect from past week in my quick project notes.

What tools should I learn to use when I develop Socket.io?

Browserify. “This is how we write code that runs both in Node and the browser. We use it for all our clients.” – Rauch. It allows to use node.js-style module system that compile for use in the browser, it supports exporting external methods and properties using the module.exports and exports variables. With browserify we can use require(./foo); function to use core modules and many of the modules on npm. [1], [2].

Mocha. “Our test framework.” – Rauch. JavaScript test framework running on node.js and the browser. It offers pretty much everything needed for asynchronous behavior-driven and test-driven development styles. [3], [4]

Zuul. “It’s how we transport tests so that they run in browsers and phones in the cloud.” – Rauch. Zuul provides and easy way to test JavaScript on different browsers without having them installed locally. It simplifies ensuring good browser coverage and supports commonly used JavaScript testing frameworks (qunitmochatapejasmine). Furthermore, it allows to switch seamlessly to cloud based testing like saucelabs for testing with hundreds of browsers and platforms.

Debug.This module is a tiny node.js & browser debugging utility for your libraries and applications. “A tiny yet incredibly useful dependency we use in all projects is called ‘debug’.” – Rauch

It says readme so I read it

It seems like the biggest issue to tackle before writing code is that you really need to know how everything works before starting to build something on your own.

Although the codebase of Engine.io is only around 1000 lines of code, understanding how supported transport protocols (XHR/JSONP polling, WebSockets and FlashSockets) work takes some time. In my opinion, in order to understand Engine.io, Socket.io and all the related projects, readme-files and test cases that arrive with the projects are essential. They describe well how things are expected to work and how functions should behave.

When it comes to Javascript, I would recommend to read Guillermo Rauch’s book Smashing Node.js. – it has also a small section about Node.js’s way to handle connections to TCP and HTTP servers which are supporting the topic.

First thing to do at the beginning of next week is to write an additional blog post which explains concepts and technologies related to this project and creating a small example project that uses Socket.io.

Understanding the problems that raised when Engine.io was created and where is this project heading to

“The central problem this poses is: how do we switch transports without losing messages? Engine only switches from polling to another transport in between polling cycles. Since the server closes the connection after a certain timeout when there’s no activity, and the polling transport implementation buffers messages in between connections, this ensures no message loss and optimal performance.” – from Engine.io readme file.

Ok, that is a good start when trying to understand what problems we are facing – but the questions remain where this project is heading to, what functionality will be developed next or which issue needs to be fixed?

All tests passing – this is a good spot to dig deeper