1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the Tidal/WampWatch package. |
5
|
|
|
* (c) 2016 Timo Michna <timomichna/yahoo.de> |
6
|
|
|
* |
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
8
|
|
|
* file that was distributed with this source code. |
9
|
|
|
* |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Tidal\WampWatch\Adapter\Thruway; |
13
|
|
|
|
14
|
|
|
use Thruway\ClientSession as ThruwaySession; |
15
|
|
|
use Tidal\WampWatch\ClientSessionInterface; |
16
|
|
|
use React\Promise\Promise as ReactPromise; |
17
|
|
|
use Tidal\WampWatch\Adapter\React\PromiseAdapter; |
18
|
|
|
|
19
|
|
|
class ClientSession implements ClientSessionInterface |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* @var ThruwaySession |
23
|
|
|
*/ |
24
|
|
|
protected $thruwaySession; |
25
|
|
|
|
26
|
|
|
public function __construct(ThruwaySession $thruwaySession) |
27
|
|
|
{ |
28
|
|
|
$this->thruwaySession = $thruwaySession; |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Subscribe. |
33
|
|
|
* |
34
|
|
|
* @param string $topicName |
35
|
|
|
* @param callable $callback |
36
|
|
|
* @param $options array |
37
|
|
|
* |
38
|
|
|
* @return PromiseAdapter |
39
|
|
|
*/ |
40
|
|
|
public function subscribe($topicName, callable $callback, $options = null) |
41
|
|
|
{ |
42
|
|
|
return $this->createPromiseAdapter( |
43
|
|
|
$this->thruwaySession->subscribe($topicName, $callback, $options) |
44
|
|
|
); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Publish. |
49
|
|
|
* |
50
|
|
|
* @param string $topicName |
51
|
|
|
* @param array|mixed $arguments |
52
|
|
|
* @param array|mixed $argumentsKw |
53
|
|
|
* @param array|mixed $options |
54
|
|
|
* |
55
|
|
|
* @return PromiseAdapter |
56
|
|
|
*/ |
57
|
|
|
public function publish($topicName, $arguments = null, $argumentsKw = null, $options = null) |
58
|
|
|
{ |
59
|
|
|
return $this->createPromiseAdapter( |
60
|
|
|
$this->thruwaySession->publish($topicName, $arguments, $argumentsKw, $options) |
61
|
|
|
); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* Register. |
66
|
|
|
* |
67
|
|
|
* @param string $procedureName |
68
|
|
|
* @param callable $callback |
69
|
|
|
* @param array|mixed $options |
70
|
|
|
* |
71
|
|
|
* @return PromiseAdapter |
72
|
|
|
*/ |
73
|
|
|
public function register($procedureName, callable $callback, $options = null) |
74
|
|
|
{ |
75
|
|
|
return $this->createPromiseAdapter( |
76
|
|
|
$this->thruwaySession->register($procedureName, $callback, $options) |
77
|
|
|
); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* Unregister. |
82
|
|
|
* |
83
|
|
|
* @param string $procedureName |
84
|
|
|
* |
85
|
|
|
* @return PromiseAdapter |
86
|
|
|
*/ |
87
|
|
|
public function unregister($procedureName) |
88
|
|
|
{ |
89
|
|
|
return $this->createPromiseAdapter( |
90
|
|
|
$this->thruwaySession->unregister($procedureName) |
|
|
|
|
91
|
|
|
); |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* Call. |
96
|
|
|
* |
97
|
|
|
* @param string $procedureName |
98
|
|
|
* @param array|mixed $arguments |
99
|
|
|
* @param array|mixed $argumentsKw |
100
|
|
|
* @param array|mixed $options |
101
|
|
|
* |
102
|
|
|
* @return PromiseAdapter |
103
|
|
|
*/ |
104
|
|
|
public function call($procedureName, $arguments = null, $argumentsKw = null, $options = null) |
105
|
|
|
{ |
106
|
|
|
return $this->createPromiseAdapter( |
107
|
|
|
$this->thruwaySession->call($procedureName, $arguments, $argumentsKw, $options) |
108
|
|
|
); |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* @param int $sessionId |
113
|
|
|
*/ |
114
|
|
|
public function setSessionId($sessionId) |
115
|
|
|
{ |
116
|
|
|
$this->thruwaySession->setSessionId($sessionId); |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* @return int the Session Id |
121
|
|
|
*/ |
122
|
|
|
public function getSessionId() |
123
|
|
|
{ |
124
|
|
|
return $this->thruwaySession->getSessionId(); |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
/** |
128
|
|
|
* @param $msg |
129
|
|
|
*/ |
130
|
|
|
public function sendMessage($msg) |
131
|
|
|
{ |
132
|
|
|
$this->thruwaySession->sendMessage($msg); |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
/** |
136
|
|
|
* @param ReactPromise $promise |
137
|
|
|
* |
138
|
|
|
* @return PromiseAdapter |
139
|
|
|
*/ |
140
|
|
|
private function createPromiseAdapter(ReactPromise $promise) |
141
|
|
|
{ |
142
|
|
|
return new PromiseAdapter($promise); |
143
|
|
|
} |
144
|
|
|
} |
145
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: