PHP Classes

File: vendor/react/event-loop/examples/04-signals.php

Recommend this page to a friend!
  Classes of Stanley Aloh   Tic Tac Toe Multiplayer   vendor/react/event-loop/examples/04-signals.php   Download  
File: vendor/react/event-loop/examples/04-signals.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Tic Tac Toe Multiplayer
Manage the interactions ofTic-Tac-Toe game players
Author: By
Last change:
Date: 9 days ago
Size: 504 bytes
 

Contents

Class file image Download
<?php

require __DIR__ . '/../vendor/autoload.php';

if (!
defined('SIGINT')) {
   
fwrite(STDERR, 'Not supported on your platform (ext-pcntl missing or Windows?)' . PHP_EOL);
    exit(
1);
}

$loop = React\EventLoop\Factory::create();

$loop->addSignal(SIGINT, $func = function ($signal) use ($loop, &$func) {
    echo
'Signal: ', (string)$signal, PHP_EOL;
   
$loop->removeSignal(SIGINT, $func);
});

echo
'Listening for SIGINT. Use "kill -SIGINT ' . getmypid() . '" or CTRL+C' . PHP_EOL;

$loop->run();