Making Websockets Sexy!

If you’re reading this then you’re probably aware of the useful but dry uses of Websocket technology. But what about the sexier end of the spectrum, what’s turning heads out there?

Last week I had the pleasure of talking at Oxford Geek Nights, a superb meetup organised by the folks at Torchbox. The meetup is spear-headed by the legendary J-P; it’s the optimal balance between geeky tech, a dash of creativity, a great bunch of locals and of course a bar.

Engaging a crowd

My plan was to detect beats in a music track and push colours to my audience’s phones in time to the music. I really didn’t want to re-invent the wheel here, so I decided to use Processing’s Minim library for the hard work.

With Minim you can detect beats (peaks in energy) like so:

Yes it’s really that simple. The beat detection is rudimentary but it hit the spot nicely for my demo.

(Note that I set the sensitivity for the beat detection to 1000ms. This means that maximum frequency of a new beat being detected is once a second. We don’t want to bombard our audience with crazy-fast colour changes!)

Each time a beat was detected I triggered an event to Pusher:

You’ll notice that I’m keeping a count of the number of colour pushes so that I can pick a new colour each time from an array.

That was my ‘server’ done, so let’s move on to the client.┬áIn this case my client is a mobile-optimised web page that the audience visit on their smarphone. Pusher makes this really easy!

$(function () {

function initPusher()
    // Connect to Pusher
    var pusher = new Pusher(PUSHER_CONFIG.APP_KEY);

    // Subscribe to colours channel
    var chColours = pusher.subscribe('rave-1');

    // Bind to colour change event
    chColours.bind('colour-change', function(data)

function changeColour(colour)
    $('body').css('background-color', colour);

Rich has completed his set…

That really is it. An incredibly simple demo to demonstrate the sexy side of Websockets.

If you’re wondering, the live coding demo went pretty well – except the WiFi in the room couldn’t cope with 100s of geeks trying to connect. Lesson learned!

Thanks again to all those at Oxford Geek Night for chance to spread Pusher goodness.

Awesome done properly

That was nice hack, but can these things be done at commercially and at scale? The answer is yes, as proven by one of our awesome customers Makelight Interactive. These guys use Pusher to create incredible live experiences at gigs, by pushing colours to phones. Think Olypmics opening ceremony, but with phones as pixels. This video does their work more justice than I possibly can:

Makelight do incredible work and they’re the guys to turn to for a flawless experience.

Ready to begin?

Start building your realtime experience today.

From in-app chat to realtime graphs and location tracking, you can rely on Pusher to scale to million of users and trillions of messages