Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to send command line live output to websocket server? #137

Open
DangerD1024 opened this issue Mar 13, 2022 · 0 comments
Open

How to send command line live output to websocket server? #137

DangerD1024 opened this issue Mar 13, 2022 · 0 comments

Comments

@DangerD1024
Copy link

$app = function (Ratchet\Client\WebSocket $conn) use ($connector, $loop, &$app, $server_id) {
    $conn->on('message', function (\Ratchet\RFC6455\Messaging\MessageInterface $msg) use ($conn) {
        global $server_id;
        $msg = json_decode($msg);
        $proc = popen("ping -t 127.0.0.1",'r');
        if($msg->type=='run') {
            while (!feof($proc))
            {
                echo $read = fread($proc, 4096);
                if($read) {
                    $conn->send($read);
                }
            }
        }
    });

Looks like while (!feof($proc)) blocks main thread...
Is there any other way to send live output to websocket server?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant