Welcome Guest, Not a member yet? Register   Sign In
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) In terms of performance websockets are more resource intensive for the server then normal http request / responses ?
2) In terms of the application itself, do you think it's easier or harder to build with websockets? Or maybe it doesn't even make sense to use websockets I dunno... For example, blog, institutional website, ecommerce, and so on...
3) What are the best scenarios to use websockets? I am not sure if websockets are here to completly dominate or if they are resource intensive and should be used for real time applications or widgets... for example... maybe use a webchat that will be in an iframe inside your normal website?

I would love to be more enlighted on this... I have made a simple chat application on heroku with a couple of lines. It is super effective in terms of code and performance for the user... I don't know about the server though...

1) http://stackoverflow.com/questions/14703...ol-vs-http
2) Depending on user experience or you can try using Sailsjs. As I know, paypal using nodejs(backend)
3) Maybe realtime webapps or SPA.

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?

(08-15-2016, 05:30 PM)Ivo Miranda Wrote: 3) Yeah real time apps for sure. What does SPA means?

SPA - Single Page Application
Codeigniter is simply one of the tools you need to learn to be a successful developer. Always add more tools to your coding arsenal!

(This post was last modified: 08-16-2016, 07:16 AM by spjonez.)

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
Enlightenment  Is  Freedom

(06-11-2021, 09:52 AM)paliz Wrote: to  make real time use pusher  its free for 100 user pre connection
i tested work well 

hello palizto, have you also successfully tried in codeigniter 4 ?

Theme © iAndrew 2016 - Forum software by © MyBB