简体   繁体   English

共享主机下的Codeigniter实时通知

[英]Codeigniter Real Time Notifications under Shared Hosting

I have tried to google but all i find related to these topics are nodejs and socket.io 我试图用谷歌搜索,但我发现所有与这些主题相关的都是nodejs和socket.io

which is fine. 很好 but problem i am facing is nodejs does not work in shared hosting. 但是我面临的问题是nodejs在共享托管中不起作用。

I want to know any way i can have real time notifications in Codeigniter while i can still use shared hosting services. 我想知道在我仍然可以使用共享托管服务的同时,我可以在Codeigniter中获得实时通知的任何方式。 I Don't have much budget to go for VPS. 我没有太多的预算去购买VPS。 i want to do it for learning purposes right now. 我想现在就出于学习目的。

I have seen Ratchet but still could not find any documentation for it to use with Codeigniter. 我已经看过Ratchet,但是仍然找不到与Codeigniter一起使用的任何文档。

-=-=-=-=-= - = - = - = - = - =

UPDATE : 更新:

I don't know how, but someone made it possible to use nodejs on shared hosting with PHP.. I have not yet tried it, but gonna try it now :) 我不知道如何,但是有人可以使用PHP在共享主机上使用nodejs。.我还没有尝试过,但是现在就可以尝试:)

feels promising as there is a demo too of it. 因为有演示,所以感觉很有希望。

Kinda of a library. 有点图书馆。 https://github.com/niutech/node.php https://github.com/niutech/node.php

Demo Link: http://juvenia.info/node_modules/jt-js-sample/ 演示链接: http : //juvenia.info/node_modules/jt-js-sample/

I had something similar to know for a project, I found a simple solution: Ajax (Jquery Ajax). 对于项目,我有一些类似的知识,我找到了一个简单的解决方案:Ajax(Jquery Ajax)。 You can make ajax requests at regular interval. 您可以定期发出ajax请求。

A specific scenario would be notification of messages in inbox. 一种特定情况是收件箱中的邮件通知。 Right now, i have 2 new messages in my inbox. 现在,我的收件箱中有2条新邮件。 Every 4 seconds, i make an ajax call. 每隔4秒钟,我会进行一次ajax调用。 There i check if there is a new message. 我在那里检查是否有新消息。 If yes, it would be 3 new messages. 如果是,则为3条新消息。 I return two values: number of messages, isChanged. 我返回两个值:消息数isChanged。

Using jquery, if isChanged is true, i update the html, else, i do nothing. 使用jquery,如果isChanged为true,则更新html,否则,我什么也不做。

This is just a simple scenario to show you how ajax can be used for notifications. 这只是一个简单的场景,向您展示如何将ajax用于通知。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM