A
A
apptimeru2016-12-23 17:38:11
PHP
apptimeru, 2016-12-23 17:38:11

How to implement chat on websockets?

Hello there is a site mostly written in php, mysql and some js for some ajax functions. Some functionality is needed, such as online text broadcasts, live comments and things like that. Can you please tell me what is the best way to do this? All that I dug up is commet servers, which are either outdated, or paid, in general, it’s not very clear, sockets that I still haven’t caught up with, is it normal to use with php or not, or do I need to install a node js server?
In general, please tell me the best option, how to be? in which direction to drip? Are there detailed tutorials on these technologies? Or better yet, video tutorials? Does it make sense to add node js as well?

Answer the question

In order to leave comments, you need to log in

8 answer(s)
N
Nwton, 2016-12-23
@Nwton

online text broadcasts, live commentaries and similar things

What to use: node js + socket io
What not to use: php + ajax

D
Denis Derepko, 2016-12-23
@uDenX

web socket

R
Rou1997, 2016-12-23
@Rou1997

The easiest way to implement it is not through sockets, but through Long polling, this is the usual AJAX, but using the fact that HTTP is based on TCP (the lowest level of sockets), and it is possible to wait a long time for a server response, such a "crutch" will provide "real-time" AJAX. Yes, it’s a “crutch”, yes, it’s not optimal in terms of server load, but it’s more easy and reliable than sockets, HTTP is even newer, and sockets are a technology from the 1980s, and WebSocket is not far from them in terms of reliability, it’s quite difficult to implement a stable connection in sockets, but if it’s still WebSocket, then first study on Node.js, then switch to PHP, as a last resort, leave Node.js, this is an ideal approach to little-known areas.

R
Rurik Rostislavich, 2016-12-23
@snipeer777

Tuts

N
Nikolai Romanovich, 2016-12-23
@MikalaiR

I can recommend faye.

O
OnYourLips, 2016-12-23
@OnYourLips

I still haven’t caught up with normal use with php or not, or do I need to install a node js server?
PHP can also be used normally.
This is the healthiest choice: you won't need to maintain both ecosystems and duplicate some of the code.
In PHP, it is customary to use Ratchet for websockets: socketo.me
The approach is similar to Node.js, but in the PHP ecosystem.

V
Victor, 2016-12-24
@Levhav

https://habrahabr.ru/company/comet-server/blog/273573/

A
Alexander, 2019-09-23
@wxmaper

Chat on WebSockets

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question