P
P
PanDar2021-05-13 14:18:17
PHP
PanDar, 2021-05-13 14:18:17

How to make php async?

Question to those who know and fumbles.

My task is to make it possible to interrupt the recording, that is, if I launch Playback in PHP AGI, then the script waits until the recording is played and goes on, but I need to check every second, through speechkit, what the person said something or not. If it says, then you need to abort playback and run another script.

The problem, as I said, is that only 1 function is executed, not two at once.

Through what can this be done? They advised sockets, but never worked with them, maybe they are not relevant here.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
PanDar, 2021-05-14
@PanDar

Solved the problem like this:

$pid = pcntl_fork();
if ($pid == -1) {
    die('Не удалось породить дочерний процесс');
} else if ($pid) {
    // код первой функции
    pcntl_wait($status); // Защита против дочерних "Зомби"-процессов
} else {
    // код второй функции
}

Run 2 functions at the same time

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question