WebSockets in PHP/CI/jQuery |
(08-15-2016, 12:41 PM)arma7x Wrote:(08-15-2016, 11:52 AM)Ivo Miranda Wrote: Hei guys. I am very interested in this topic. I have tried node.js in heroku and it seems pretty nice. A couple of doubts: 1) Maybe I wasn't clear... It's obvious that for a real time application websockets will be better. The problem is... Most of the applications do not require a real time connection. Would it be better to leave a websocket always open? Or to update content through ajax? Or as far as server is concerned it's more or less the same thing? 2) Using nodejs doesn't mean they are using websockets all over. You can use javascript serverside without websockets 3) Yeah real time apps for sure. What does SPA means?
Use socket.io. If you want to emit messages from both PHP and JS you'll need a socket.io server (Node) using the socket.io-redis adapter and a Redis server. They have a PHP event emitter which pushes messages into Redis and the JS server subscribes to it. The client subscribes and publishes to the node server.
You May check this thread https://forum.codeigniter.com/thread-75104.html
I use the Paho.MQTT javascript library to connect to an mqtt server. When things happen php side eg order received, payment received etc, they publish messages to the mqtt server which looks after notifying any web pages which have subscribed to the relevant topics.
to make real time use pusher its free for 100 user pre connection
i tested work well https://pusher.com/
Enlightenment Is Freedom
(06-11-2021, 09:52 AM)paliz Wrote: to make real time use pusher its free for 100 user pre connection hello palizto, have you also successfully tried in codeigniter 4 ? |
Welcome Guest, Not a member yet? Register Sign In |