M
M
madc0de2018-08-09 16:56:33
PHP
madc0de, 2018-08-09 16:56:33

How to use socket in php project?

There is a project in php, a regular site. You need to add a block with sports matches and their odds.
Found api, everything is fine, but how to make everything updated in live mode?
Previously, I worked only with Ajax and it only occurs to me to send an Ajax request to the server every 5 seconds.
Please advise how to be in this situation, what technology or bundle to use?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
H
hOtRush, 2018-08-09
@hOtRush

https://github.com/centrifugal/centrifugal

A
Alexander Taratin, 2018-08-09
@Taraflex

Server sent event - but not supported in ie/edge
https://learn.javascript.ru/server-sent-events
https://www.npmjs.com/package/event-source-polyfill

A
Alexander Aksentiev, 2018-08-09
@Sanasol

Why do you need realtime so realtime?
Ajax is enough.
Well, let’s check that the odds have changed since the page was loaded and when you try to bet with the old odds.

K
Konstantin Malyarov, 2018-08-09
@Konstantin18ko

There are two options:
1. setTimeout, setInterval
2. Websocket

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question