Answer the question
In order to leave comments, you need to log in
Dialogue between two users. What to choose, how to decide?
Good day to all!
Working further on my project, I thought to make a communication between two users, it looks more like a dialogue like on Twitter, I searched the Internet for a solution, I wrote a code using Ajax-pooling, but after looking at the reviews for such a solution to problems - not very positive . Breaking the whole internet, I came across some Node.js and socket.io. Having tried it, I liked it, the load on the server does not take, and updates every few seconds are not needed.
The problem is... how do I enable these files if I have an Apache server? how to make socket.io work in php? what do you advise? what libraries are better to use?
In socket.io it refers to the file it will work with,
here.. example..
var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io')(http);
app.get('/', function(req, res){
res.sendFile('index.html'); // ссылка на файл
});
Answer the question
In order to leave comments, you need to log in
socket.io cannot be made to work in php, since it is written in JS.
But you can google web socket and comet.
And it is better to leave the code using ajax-pooling'a. And rewrite everything when you start having performance problems (probably never).
For PHP there is a chic implementation of WebSockets - Ratchet .
Replace Apache with nginx and you'll find hundreds of deployment templates like nginx + php + node. Or put nginx in front of Apache and send static from it, and the rest of the requests through a reverse proxy in Apache and on another port in node.js.
Maybe it's better to link with JS on the front? I can send my chat, which I wrote using these technologies. On the kohan server (you can just php), node js + socket.io, and on the front html, css, javascript, jquery
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question