roshkattu roshkattu - 5 months ago 130
Node.js Question

Node.js + Socket.IO and CodeIgniter

I am working on a project that's developed with the CodeIgniter framework. My project has a lot of user interaction like posts, comments, and other notifications that should be live.

I have tried by now to get those notifications in two ways:

1. I've tried to build a sort of data pull system with AJAX but in my opinion this was making lots of bandwidth waste on my server

2. I've set up a node.js with server, that only listens for some socket events and pushes the notifications back to the user. For example, when a comment is added, instead having a function that pulls all the new comments from 5 to 5 seconds, I'm having a socket.emit(); that pushes the comment information to node.js and node.js pushes the notification to all connected sockets.

I am not sure if node.js + PHP is a good job ( but, what I've learnt so far is that node.js is good for long polling and less resource costs ).

Witch architecture would you consider is better?


Use Node.js with Socket.IO to get any live data to your clients.

Yes, you can use this in conjunction with your CodeIgniter-based site... outputting dynamic pages and getting data client-side don't have to have anything to do with each other.

The issue you had with Socket.IO wasn't with Socket.IO itself... it's with how you built your application. Emit messages as you need to. If you need an initial emit with 5 comments upon connect, do that.