doutu4335 2014-04-19 01:38
浏览 129

使用node.js作为长轮询的代理

I have a chat app for mobile devices which uses a php REST service to communicate.

Everything works fine but would like to use long poll to query new messages to reduce battery consumption and bandwidth on devices.

I have investigated a bit and seems that apache is not well suited for this type of requests because of its threading model.

Node.js instead seems to use event driven execution which perfectly fits this use but I would like to keep my php service, so was thinking about create a node server which handles the long poll and it polls the php service until data is available (both services will be on openshift)

So, the questions:

1-is there a better way to do this?

2-if no, how it should be handled on node server (code examples please, not pseudo code, I know i must retain the connection, create an async task to poll, etc etc, but its my first program for node.js and i am a bit lost)

Thanks.

Edit

Use of Push services are discarded because mobile app is distributed in house, so no gcm nor Apple push

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥30 这是哪个作者做的宝宝起名网站
    • ¥60 版本过低apk如何修改可以兼容新的安卓系统
    • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
    • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
    • ¥50 有数据,怎么用matlab求全要素生产率
    • ¥15 TI的insta-spin例程
    • ¥15 完成下列问题完成下列问题
    • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
    • ¥15 YoloV5 第三方库的版本对照问题
    • ¥15 请完成下列相关问题!