Summary

We started out this chapter by looking at the current problems facing our application. Following this, we looked at how web sockets can solve our problem and found a fully featured implementation of web sockets in the socket.io library. The basics of socket.io were covered in addition to how it was going to work with the current application. We then went on to actually implementing the socket.io library in both the client-side as well as the server-side application code and finally inspected the network activity in both cases to observe the difference.

Although web sockets seem like a solution to all our problems, there are still some drawbacks that we should consider:

  • Web sockets are more resource-intensive compared to HTTP calls since each connection to the server is maintained as a separate instance and exists for as long as the client is active. HTTP calls, on the other hand, conclude when a response is sent by the server.
  • While web sockets may work on almost all modern browsers, its support is still lacking in older browsers such as IE9 and Opera Mini.

Overall, web sockets should be utilized depending on the use case and considering the trade-offs involved.

Up until this point, everything we have worked on has been running on the Pi. In the next chapters, we will take off and break away from the confines of our Pi's hardware and move a lot of the functionality in our application to the cloud!

 

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.151.106