2017-10-07

Websockets are awesome

There are some things that modern browsers do that most people do not realise, and which are awesome. One is svg, which is a whole other blog post, but the other is websockets.

They are awesome as they allow a web page to connect to some resource and keep that connection alive and open whilst that page is open, and asynchronously send or receive data on that connection.

Yes, this seems like something that has been possible on an RS232 cable for a while, but actually from a user interface point of view it is pretty big. It allows messages (blocks of data) to be sent and received. I am using JSON objects, but it could be anything.

My main application, and why I put together my own websocket server library, is to allow my alarm system to do stuff using web sockets. It means we should be able to do a floor plan with images of PIRs and doors and all sorts, updating in real time, and clickable to do things. That will be magic for installing the alarm and walking around with an iPad, but also for remote monitoring. Imagine making a page with embedded security camera footage, and so on in with sensors and doors and so on.

Today I bolted on the web socket library to the core alarm system, and all I added were a few lines of code to mirror the keypad on the system. It just worked, and a couple of lines of javascript and it looks magic.


5 comments:

  1. And also eventsource, if you only need to get data from server to browser.

    https://www.w3schools.com/html/html5_serversentevents.asp

    ReplyDelete
  2. Can you click on the buttons on the image and have it work the other way too?

    ReplyDelete
    Replies
    1. Yes, and I can do way more now - open doors, set and unset alarm groups, all sorts.

      Delete
  3. The non mono spaced font is annoying :p

    ReplyDelete

Comments are moderated purely to filter out obvious spam, but it means they may not show immediately.

Don't use UPS to ship to UK

I posted about shipping and importing and tax and duty - general info. But this is specific. DON'T USE UPS! I had assumed the UPS issue ...