Apply fixes from StyleCI

This commit is contained in:
Daniil Gentili 2018-03-03 17:23:27 +00:00 committed by StyleCI Bot
parent 9014506ef5
commit 28921b4db4
3 changed files with 28 additions and 16 deletions

View File

@ -1,4 +1,3 @@
<?php
require 'vendor/autoload.php';

View File

@ -20,10 +20,14 @@ class Server
{
private $settings;
private $pids = [];
public function __construct($settings) {
public function __construct($settings)
{
$this->settings = $settings;
}
public function start() {
public function start()
{
pcntl_signal(SIGTERM, [$this, 'sig_handler']);
pcntl_signal(SIGINT, [$this, 'sig_handler']);
pcntl_signal(SIGCHLD, [$this, 'sig_handler']);
@ -36,26 +40,30 @@ class Server
$this->handle($this->sock->accept());
}
}
private function handle($socket) {
private function handle($socket)
{
$pid = pcntl_fork();
if ($pid == -1) {
die('could not fork');
} else if ($pid) {
die('could not fork');
} elseif ($pid) {
return $this->pids[] = $pid;
}
$handler = new \danog\MadelineProto\Server\Handler($socket);
$handler->loop();
die;
}
public function __destruct() {
public function __destruct()
{
foreach ($this->pid as $pid) {
pcntl_wait($pid);
}
}
public function sig_handler($sig)
{
switch($sig)
{
switch ($sig) {
case SIGTERM:
case SIGINT:
exit();

View File

@ -19,16 +19,21 @@ namespace danog\MadelineProto\Server;
class Handler
{
private $socket;
public function __construct($socket) {
public function __construct($socket)
{
$this->socket = $socket;
}
public function loop() {
public function loop()
{
}
public function read_payload() {
public function read_payload()
{
}
public function write_payload($payload) {
public function write_payload($payload)
{
}
}
}