S
S
Sergey Maley2015-05-13 23:25:41
PHP
Sergey Maley, 2015-05-13 23:25:41

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'); // ссылка на файл
});


But what if I have a modal window, and it works in many files?
I'm planning to write a dialog script that will work in a similar way as in twitter, that is, in a modal window. I need any help in solving the problem. I don’t even know where to turn for help ... Google and YouTube dug upside down, but I didn’t find how to do it in php files with mySql, apache (MAMP). I look forward to your advice and help. Thanks in advance.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
R
Rishat Kadyrov, 2015-05-13
@spesher

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).

E
Evgeny Lebedev, 2015-05-13
@HollowJ

For PHP there is a chic implementation of WebSockets - Ratchet .

T
Timur Shemsedinov, 2015-05-13
@MarcusAurelius

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.

E
Empty User, 2015-05-14
@dimash07

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 question

Ask a Question

731 491 924 answers to any question