|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* \AppserverIo\Server\Handlers\RequestHandlerThread |
|
5
|
|
|
* |
|
6
|
|
|
* NOTICE OF LICENSE |
|
7
|
|
|
* |
|
8
|
|
|
* This source file is subject to the Open Software License (OSL 3.0) |
|
9
|
|
|
* that is available through the world-wide-web at this URL: |
|
10
|
|
|
* http://opensource.org/licenses/osl-3.0.php |
|
11
|
|
|
* |
|
12
|
|
|
* PHP version 5 |
|
13
|
|
|
* |
|
14
|
|
|
* @author Johann Zelger <[email protected]> |
|
15
|
|
|
* @copyright 2015 TechDivision GmbH <[email protected]> |
|
16
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
|
17
|
|
|
* @link https://github.com/appserver-io/server |
|
18
|
|
|
* @link http://www.appserver.io |
|
19
|
|
|
*/ |
|
20
|
|
|
|
|
21
|
|
|
namespace AppserverIo\Server\Handlers; |
|
22
|
|
|
|
|
23
|
|
|
use AppserverIo\Server\Interfaces\ServerContextInterface; |
|
24
|
|
|
use AppserverIo\Server\Interfaces\WorkerInterface; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* This class is just for testing purpose, so please don't use it for this moment. |
|
28
|
|
|
* |
|
29
|
|
|
* @author Johann Zelger <[email protected]> |
|
30
|
|
|
* @copyright 2015 TechDivision GmbH <[email protected]> |
|
31
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
|
32
|
|
|
* @link https://github.com/appserver-io/server |
|
33
|
|
|
* @link http://www.appserver.io |
|
34
|
|
|
*/ |
|
35
|
|
|
class RequestHandlerThread extends \Thread |
|
36
|
|
|
{ |
|
37
|
|
|
/** |
|
38
|
|
|
* Constructs the request handler thread and start's it |
|
39
|
|
|
* |
|
40
|
|
|
* @param resource $connectionResource The connection resource |
|
41
|
|
|
* @param array $connectionHandlers An array of connection handlers |
|
42
|
|
|
* @param \AppserverIo\Server\Interfaces\ServerContextInterface $serverContext The server's context |
|
43
|
|
|
* @param \AppserverIo\Server\Interfaces\WorkerInterface $worker The worker instance |
|
44
|
|
|
*/ |
|
45
|
|
|
public function __construct( |
|
46
|
|
|
$connectionResource, |
|
47
|
|
|
array $connectionHandlers, |
|
48
|
|
|
ServerContextInterface $serverContext, |
|
49
|
|
|
WorkerInterface $worker |
|
50
|
|
|
) { |
|
51
|
|
|
$this->connectionResource = $connectionResource; |
|
|
|
|
|
|
52
|
|
|
$this->connectionHandlers = $connectionHandlers; |
|
|
|
|
|
|
53
|
|
|
$this->serverContext = $serverContext; |
|
|
|
|
|
|
54
|
|
|
$this->worker = $worker; |
|
|
|
|
|
|
55
|
|
|
$this->start(); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* Runs workload |
|
60
|
|
|
* |
|
61
|
|
|
* @return void |
|
62
|
|
|
*/ |
|
63
|
|
|
public function run() |
|
64
|
|
|
{ |
|
65
|
|
|
// setup environment for handler |
|
66
|
|
|
require SERVER_AUTOLOADER; |
|
67
|
|
|
|
|
68
|
|
|
// set local var refs |
|
69
|
|
|
$serverContext = $this->serverContext; |
|
|
|
|
|
|
70
|
|
|
$connectionHandlers = $this->connectionHandlers; |
|
|
|
|
|
|
71
|
|
|
$worker = $this->worker; |
|
|
|
|
|
|
72
|
|
|
|
|
73
|
|
|
// get socket type |
|
74
|
|
|
$socketType = $serverContext->getServerConfig()->getSocketType(); |
|
75
|
|
|
|
|
76
|
|
|
// get connection instance by resource |
|
77
|
|
|
$connection = $socketType::getInstance($this->connectionResource); |
|
|
|
|
|
|
78
|
|
|
|
|
79
|
|
|
// iterate all connection handlers to handle connection right |
|
80
|
|
|
foreach ($connectionHandlers as $connectionHandler) { |
|
81
|
|
|
// if connectionHandler handled connection than break out of foreach |
|
82
|
|
|
if ($connectionHandler->handle($connection, $worker)) { |
|
83
|
|
|
break; |
|
84
|
|
|
} |
|
85
|
|
|
} |
|
86
|
|
|
} |
|
87
|
|
|
} |
|
88
|
|
|
|
Since your code implements the magic setter
_set, this function will be called for any write access on an undefined variable. You can add the@propertyannotation to your class or interface to document the existence of this variable.Since the property has write access only, you can use the @property-write annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.