1313
1414use Thruway \ClientSession as ThruwaySession ;
1515use Tidal \WampWatch \ClientSessionInterface ;
16+ use React \Promise \Promise as ReactPromise ;
17+ use Tidal \WampWatch \Adapter \React \PromiseAdapter ;
1618
1719class ClientSession implements ClientSessionInterface
1820{
@@ -33,11 +35,13 @@ public function __construct(ThruwaySession $thruwaySession)
3335 * @param callable $callback
3436 * @param $options array
3537 *
36- * @return \React\Promise\Promise
38+ * @return PromiseAdapter
3739 */
3840 public function subscribe ($ topicName , callable $ callback , $ options = null )
3941 {
40- return $ this ->thruwaySession ->subscribe ($ topicName , $ callback , $ options );
42+ return $ this ->createPromiseAdapter (
43+ $ this ->thruwaySession ->subscribe ($ topicName , $ callback , $ options )
44+ );
4145 }
4246
4347 /**
@@ -48,11 +52,13 @@ public function subscribe($topicName, callable $callback, $options = null)
4852 * @param array|mixed $argumentsKw
4953 * @param array|mixed $options
5054 *
51- * @return \React\Promise\Promise
55+ * @return PromiseAdapter
5256 */
5357 public function publish ($ topicName , $ arguments = null , $ argumentsKw = null , $ options = null )
5458 {
55- return $ this ->thruwaySession ->publish ($ topicName , $ arguments , $ argumentsKw , $ options );
59+ return $ this ->createPromiseAdapter (
60+ $ this ->thruwaySession ->publish ($ topicName , $ arguments , $ argumentsKw , $ options )
61+ );
5662 }
5763
5864 /**
@@ -62,23 +68,27 @@ public function publish($topicName, $arguments = null, $argumentsKw = null, $opt
6268 * @param callable $callback
6369 * @param array|mixed $options
6470 *
65- * @return \React\Promise\Promise
71+ * @return PromiseAdapter
6672 */
6773 public function register ($ procedureName , callable $ callback , $ options = null )
6874 {
69- return $ this ->thruwaySession ->register ($ procedureName , $ callback , $ options );
75+ return $ this ->createPromiseAdapter (
76+ $ this ->thruwaySession ->register ($ procedureName , $ callback , $ options )
77+ );
7078 }
7179
7280 /**
7381 * Unregister.
7482 *
7583 * @param string $procedureName
7684 *
77- * @return \React\Promise\Promise
85+ * @return PromiseAdapter
7886 */
7987 public function unregister ($ procedureName )
8088 {
81- return $ this ->thruwaySession ->unregister ($ procedureName );
89+ return $ this ->createPromiseAdapter (
90+ $ this ->thruwaySession ->unregister ($ procedureName )
91+ );
8292 }
8393
8494 /**
@@ -89,11 +99,13 @@ public function unregister($procedureName)
8999 * @param array|mixed $argumentsKw
90100 * @param array|mixed $options
91101 *
92- * @return \React\Promise\Promise
102+ * @return PromiseAdapter
93103 */
94104 public function call ($ procedureName , $ arguments = null , $ argumentsKw = null , $ options = null )
95105 {
96- return $ this ->thruwaySession ->call ($ procedureName , $ arguments , $ argumentsKw , $ options );
106+ return $ this ->createPromiseAdapter (
107+ $ this ->thruwaySession ->call ($ procedureName , $ arguments , $ argumentsKw , $ options )
108+ );
97109 }
98110
99111 /**
@@ -112,8 +124,21 @@ public function getSessionId()
112124 return $ this ->thruwaySession ->getSessionId ();
113125 }
114126
127+ /**
128+ * @param $msg
129+ */
115130 public function sendMessage ($ msg )
116131 {
117132 $ this ->thruwaySession ->sendMessage ($ msg );
118133 }
134+
135+ /**
136+ * @param ReactPromise $promise
137+ *
138+ * @return PromiseAdapter
139+ */
140+ private function createPromiseAdapter (ReactPromise $ promise )
141+ {
142+ return new PromiseAdapter ($ promise );
143+ }
119144}
0 commit comments