@@ 35-68 (lines=34) @@ | ||
32 | * |
|
33 | * @author Adam Kadlec <[email protected]> |
|
34 | */ |
|
35 | final class OnAfterIncomingMessageHandler |
|
36 | { |
|
37 | /** |
|
38 | * Implement nette smart magic |
|
39 | */ |
|
40 | use Nette\SmartObject; |
|
41 | ||
42 | /** |
|
43 | * @var Session\SwitchableSession |
|
44 | */ |
|
45 | private $session; |
|
46 | ||
47 | /** |
|
48 | * @param Session\SwitchableSession $session |
|
49 | */ |
|
50 | public function __construct( |
|
51 | Session\SwitchableSession $session |
|
52 | ) { |
|
53 | $this->session = $session; |
|
54 | } |
|
55 | ||
56 | /** |
|
57 | * @param WebSocketsEntities\Clients\IClient $from |
|
58 | * @param WebSocketsHttp\IRequest $httpRequest |
|
59 | * |
|
60 | * @return void |
|
61 | */ |
|
62 | public function __invoke(WebSocketsEntities\Clients\IClient $from, WebSocketsHttp\IRequest $httpRequest) |
|
63 | { |
|
64 | if ($this->session instanceof Session\SwitchableSession) { |
|
65 | $this->session->detach(); |
|
66 | } |
|
67 | } |
|
68 | } |
|
69 |
@@ 35-68 (lines=34) @@ | ||
32 | * |
|
33 | * @author Adam Kadlec <[email protected]> |
|
34 | */ |
|
35 | final class OnClientDisconnectedHandler |
|
36 | { |
|
37 | /** |
|
38 | * Implement nette smart magic |
|
39 | */ |
|
40 | use Nette\SmartObject; |
|
41 | ||
42 | /** |
|
43 | * @var Session\SwitchableSession |
|
44 | */ |
|
45 | private $session; |
|
46 | ||
47 | /** |
|
48 | * @param Session\SwitchableSession $session |
|
49 | */ |
|
50 | public function __construct( |
|
51 | Session\SwitchableSession $session |
|
52 | ) { |
|
53 | $this->session = $session; |
|
54 | } |
|
55 | ||
56 | /** |
|
57 | * @param WebSocketsEntities\Clients\IClient $client |
|
58 | * @param WebSocketsHttp\IRequest $httpRequest |
|
59 | * |
|
60 | * @return void |
|
61 | */ |
|
62 | public function __invoke(WebSocketsEntities\Clients\IClient $client, WebSocketsHttp\IRequest $httpRequest) |
|
63 | { |
|
64 | if ($this->session instanceof Session\SwitchableSession) { |
|
65 | $this->session->detach(); |
|
66 | } |
|
67 | } |
|
68 | } |
|
69 |