krische online a mundane site for a mundane life

20Feb/124

A Push Notification Relay System Using Node.js and Socket.io

Background

For one of the pet projects I'm working on, I really want to create a push notification system. The site itself is written with PHP using the Kohana Framework. This works great and was a super fast and easy way to get things up and running. However, as I found out, this system isn't really conducive to the "push" notification system I wanted. I originally went with the tried & true method of long polling. Using an PHP/AJAX example I found, I got it working. But I knew this wasn't really the ideal solution.

I did more searching around, and was reading about Web Sockets that are part of the HTML 5 spec. I eventually came across the node.js plugin Socket.IO. Now I was already using PHP and Apache for my web application, so I didn't want to have to redo it all to be a node.js website. So instead, I set out to create "relay" system that clients could subscribe to and my PHP scripts could send notifications too. After playing around, it wasn't too difficult to get working.

Filed under: Web Continue reading