|
| __construct (\ThreadedLogger $logger, \ClassLoader $loader, $port, $interface="0.0.0.0") |
|
| isShutdown () |
|
| shutdown () |
|
| getPort () |
|
| getInterface () |
|
| getLogger () |
|
| getExternalQueue () |
|
| getInternalQueue () |
|
| pushMainToThreadPacket ($str) |
|
| readMainToThreadPacket () |
|
| pushThreadToMainPacket ($str) |
|
| readThreadToMainPacket () |
|
| shutdownHandler () |
|
| errorHandler ($errno, $errstr, $errfile, $errline, $context, $trace=null) |
|
| getTrace ($start=1, $trace=null) |
|
| cleanPath ($path) |
|
| run () |
|
| getCreatorId () |
|
| getThreadId () |
|
| isJoined () |
|
| isStarted () |
|
| join () |
|
| start (int $options=PTHREADS_INHERIT_ALL) |
|
| chunk ($size, bool $preserve=false) |
|
| count () |
|
| isRunning () |
|
| isTerminated () |
|
| merge ($from, $overwrite=true) |
|
| notify () |
|
| notifyOne () |
|
| offsetGet ($offset) |
|
| offsetSet ($offset, $value) |
|
| offsetExists ($offset) |
|
| offsetUnset ($offset) |
|
| pop () |
|
| run () |
|
| shift () |
|
| synchronized (\Closure $function, $args=null) |
|
| wait ($timeout) |
|
| getRefCount () |
|
| addRef () |
|
| delRef () |
|
| isGarbage () |
|
◆ __construct()
- Parameters
-
\ThreadedLogger | $logger | |
\ClassLoader | $loader | |
int | $port | |
string | $interface | |
- Exceptions
-
46 $this->port = (int)
$port;
47 if($port < 1 or $port > 65536){
48 throw new \Exception(
"Invalid port range");
60 $this->externalQueue = new \Threaded;
61 $this->internalQueue = new \Threaded;
63 if(\Phar::running(
true) !==
""){
64 $this->mainPath = \Phar::running(
true);
66 $this->mainPath = \getcwd() . DIRECTORY_SEPARATOR;
◆ addDependency()
addDependency |
( |
array & |
$loadPaths, |
|
|
\ReflectionClass |
$dep |
|
) |
| |
|
protected |
72 if($dep->getFileName() !==
false){
73 $loadPaths[$dep->getName()] = $dep->getFileName();
76 if($dep->getParentClass() instanceof \ReflectionClass){
◆ cleanPath()
212 return rtrim(str_replace([
"\\",
".php",
"phar://", rtrim(str_replace([
"\\",
"phar://"], [
"/",
""], $this->mainPath),
"/")], [
"/",
"",
"",
""], $path),
"/");
◆ errorHandler()
errorHandler |
( |
|
$errno, |
|
|
|
$errstr, |
|
|
|
$errfile, |
|
|
|
$errline, |
|
|
|
$context, |
|
|
|
$trace = null |
|
) |
| |
145 if(error_reporting() === 0){
149 E_ERROR =>
"E_ERROR",
150 E_WARNING =>
"E_WARNING",
151 E_PARSE =>
"E_PARSE",
152 E_NOTICE =>
"E_NOTICE",
153 E_CORE_ERROR =>
"E_CORE_ERROR",
154 E_CORE_WARNING =>
"E_CORE_WARNING",
155 E_COMPILE_ERROR =>
"E_COMPILE_ERROR",
156 E_COMPILE_WARNING =>
"E_COMPILE_WARNING",
157 E_USER_ERROR =>
"E_USER_ERROR",
158 E_USER_WARNING =>
"E_USER_WARNING",
159 E_USER_NOTICE =>
"E_USER_NOTICE",
160 E_STRICT =>
"E_STRICT",
161 E_RECOVERABLE_ERROR =>
"E_RECOVERABLE_ERROR",
162 E_DEPRECATED =>
"E_DEPRECATED",
163 E_USER_DEPRECATED =>
"E_USER_DEPRECATED",
165 $errno = isset($errorConversion[$errno]) ? $errorConversion[$errno] : $errno;
166 if(($pos = strpos($errstr,
"\n")) !==
false){
167 $errstr = substr($errstr, 0, $pos);
172 $this->
getLogger()->debug(
"An $errno error happened: \"$errstr\" in \"$errfile\" at line $errline");
174 foreach(($trace = $this->
getTrace($trace === null ? 3 : 0, $trace)) as $i => $line){
◆ getExternalQueue()
◆ getInterface()
◆ getInternalQueue()
◆ getLogger()
◆ getPort()
◆ getTrace()
getTrace |
( |
|
$start = 1 , |
|
|
|
$trace = null |
|
) |
| |
183 if(function_exists(
"xdebug_get_function_stack")){
184 $trace = array_reverse(xdebug_get_function_stack());
186 $e = new \Exception();
187 $trace = $e->getTrace();
193 for($i = (
int) $start; isset($trace[$i]); ++$i, ++$j){
195 if(isset($trace[$i][
"args"]) or isset($trace[$i][
"params"])){
196 if(isset($trace[$i][
"args"])){
197 $args = $trace[$i][
"args"];
199 $args = $trace[$i][
"params"];
201 foreach($args as $name => $value){
202 $params .= (is_object($value) ? get_class($value) .
" " . (method_exists($value,
"__toString") ? $value->__toString() :
"object") : gettype($value) .
" " . @strval($value)) .
", ";
205 $messages[] =
"#$j " . (isset($trace[$i][
"file"]) ? $this->
cleanPath($trace[$i][
"file"]) :
"") .
"(" . (isset($trace[$i][
"line"]) ? $trace[$i][
"line"] :
"") .
"): " . (isset($trace[$i][
"class"]) ? $trace[$i][
"class"] . (($trace[$i][
"type"] ===
"dynamic" or $trace[$i][
"type"] ===
"->") ?
"->" :
"::") :
"") . $trace[$i][
"function"] .
"(" . substr($params, 0, -2) .
")";
◆ isShutdown()
◆ pushMainToThreadPacket()
pushMainToThreadPacket |
( |
|
$str | ) |
|
123 $this->internalQueue[] = $str;
◆ pushThreadToMainPacket()
pushThreadToMainPacket |
( |
|
$str | ) |
|
131 $this->externalQueue[] = $str;
◆ readMainToThreadPacket()
readMainToThreadPacket |
( |
| ) |
|
127 return $this->internalQueue->shift();
◆ readThreadToMainPacket()
readThreadToMainPacket |
( |
| ) |
|
135 return $this->externalQueue->shift();
◆ run()
218 foreach($this->loadPaths as $name => $path){
219 if(!class_exists($name,
false) and !interface_exists($name,
false)){
223 $this->loader->register(
true);
227 ini_set(
"display_errors", 1);
228 ini_set(
"display_startup_errors", 1);
230 set_error_handler([$this,
"errorHandler"], E_ALL);
231 register_shutdown_function([$this,
"shutdownHandler"]);
234 $socket =
new UDPServerSocket($this->
getLogger(), $this->port, $this->interface);
235 new SessionManager($this, $socket);
236 }
catch(\Throwable $e){
237 $this->logger->logException($e);
◆ shutdown()
◆ shutdownHandler()
140 $this->
getLogger()->emergency(
"RakLib crashed!");
◆ $externalQueue
◆ $interface
◆ $internalQueue
◆ $loader
◆ $loadPaths
◆ $logger
◆ $mainPath
◆ $port
◆ $shutdown
The documentation for this class was generated from the following file:
- src/raklib/server/RakLibServer.php