简体   繁体   中英

How can we use socket.io for real time chat conversation in core php without using node.js

I am trying to use socket.io in core php with custom framework. I don't want to use node.js as this will create issues with my existing(AJAX) code.

1) Is there any way to use it without node.js? 2) If that is required then is there any way we can use it with ajax? below is how we are using AJAX.

for work on real time chat i am using this.

setInterval(function() { 
    $.ajax({
        url: 'myajax.php',
        dataType: "json",
        data:$('form').serialize(),
        success: function(response){
            $('.chat-log').append(response.logdata);
        }
    })
},1000);

can anyone tell me to get the realtime response with it or some other method.

Socket.io basically is the WEBSOCKET technology you can use this in jquery or any frontend library using socket.io or using by default ws:// function.

for php write in this websocket you need to open this socket port first like if you :1003 (socket port).

then you use elephant.io in php to write and read websocket inside php script.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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