dongnai5905 2012-09-22 13:50
浏览 117
已采纳

Node.js + Socket.IO和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 socket.io 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?

  • 写回答

2条回答 默认 最新

  • doufu5521 2012-09-22 13:55
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘