mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 09:56:06 +00:00
Fixed random timeout #11
This commit is contained in:
@ -298,7 +298,6 @@ class PocketMinecraftServer extends stdClass{
|
||||
$this->loadEvents();
|
||||
declare(ticks=15);
|
||||
register_tick_function(array($this, "tick"));
|
||||
$this->event("onTick", "tickerFunction", true);
|
||||
register_shutdown_function(array($this, "close"));
|
||||
console("[INFO] Server started!");
|
||||
$this->process();
|
||||
@ -309,6 +308,7 @@ class PocketMinecraftServer extends stdClass{
|
||||
if($this->lastTick <= ($time - 0.05)){
|
||||
$this->tickMeasure[] = $this->lastTick = $time;
|
||||
array_shift($this->tickMeasure);
|
||||
$this->tickerFunction($time);
|
||||
$this->trigger("onTick", $time);
|
||||
}
|
||||
}
|
||||
|
@ -52,7 +52,10 @@ class Session{
|
||||
$this->counter = array(0, 0);
|
||||
}
|
||||
|
||||
public function onTick($time){
|
||||
public function onTick($time, $event){
|
||||
if($event !== "onTick"){
|
||||
return;
|
||||
}
|
||||
if($time > $this->timeout){
|
||||
$this->close("timeout");
|
||||
}else{
|
||||
@ -169,7 +172,7 @@ class Session{
|
||||
}
|
||||
}
|
||||
|
||||
public function handle($pid, &$data){
|
||||
public function handle($pid, $data){
|
||||
if($this->connected === true){
|
||||
$this->timeout = microtime(true) + 25;
|
||||
switch($pid){
|
||||
@ -397,7 +400,7 @@ class Session{
|
||||
$this->buffer[$count] = array($id, $data);
|
||||
}
|
||||
$data["id"] = $id;
|
||||
$this->send(0x84, array(
|
||||
$this->send(0x80, array(
|
||||
$count,
|
||||
0x00,
|
||||
$data,
|
||||
|
Reference in New Issue
Block a user