1 | <?php |
||
34 | class RemoteContextConnection implements ConnectionInterface |
||
35 | { |
||
36 | |||
37 | /** |
||
38 | * The default transport to use. |
||
39 | * |
||
40 | * @var string |
||
41 | */ |
||
42 | const DEFAULT_SCHEME = 'http'; |
||
43 | |||
44 | /** |
||
45 | * The default client sockets IP address. |
||
46 | * |
||
47 | * @var string |
||
48 | */ |
||
49 | const DEFAULT_HOST = '127.0.0.1'; |
||
50 | |||
51 | /** |
||
52 | * The default client sockets port. |
||
53 | * |
||
54 | * @var integer |
||
55 | */ |
||
56 | const DEFAULT_PORT = 8585; |
||
57 | |||
58 | /** |
||
59 | * The default transport to use. |
||
60 | * |
||
61 | * @var string |
||
62 | */ |
||
63 | protected $transport = RemoteContextConnection::DEFAULT_SCHEME; |
||
64 | |||
65 | /** |
||
66 | * The client socket's IP address. |
||
67 | * |
||
68 | * @var string |
||
69 | */ |
||
70 | protected $address = RemoteContextConnection::DEFAULT_HOST; |
||
71 | |||
72 | /** |
||
73 | * The client socket's port. |
||
74 | * |
||
75 | * @var integer |
||
76 | */ |
||
77 | protected $port = RemoteContextConnection::DEFAULT_PORT; |
||
78 | |||
79 | /** |
||
80 | * The name of the webapp using this client connection. |
||
81 | * |
||
82 | * @var string |
||
83 | */ |
||
84 | protected $appName; |
||
85 | |||
86 | /** |
||
87 | * The storage for the sessions. |
||
88 | * |
||
89 | * @var \AppserverIo\Collections\CollectionInterface |
||
90 | */ |
||
91 | protected $sessions = null; |
||
92 | |||
93 | /** |
||
94 | * Parser to process the remote method call. |
||
95 | * |
||
96 | * @var \AppserverIo\RemoteMethodInvocation\RemoteMethodCallParser |
||
97 | */ |
||
98 | protected $parser; |
||
99 | |||
100 | /** |
||
101 | * Injects the collection for the sessions. |
||
102 | * |
||
103 | * @param \AppserverIo\Collections\CollectionInterface $sessions The collection for the sessions |
||
104 | * |
||
105 | * @return void |
||
106 | */ |
||
107 | public function injectSessions(CollectionInterface $sessions) |
||
111 | |||
112 | /** |
||
113 | * Returns the collection with the sessions. |
||
114 | * |
||
115 | * @return \AppserverIo\Collections\CollectionInterface The collection with the sessions |
||
116 | */ |
||
117 | public function getSessions() |
||
121 | |||
122 | /** |
||
123 | * Injects the remote method call parser. |
||
124 | * |
||
125 | * @param \AppserverIo\RemoteMethodInvocation\RemoteMethodCallParser $parser The remote method call parser |
||
126 | * |
||
127 | * @return void |
||
128 | */ |
||
129 | public function injectParser(RemoteMethodCallParser $parser) |
||
133 | |||
134 | /** |
||
135 | * Returns the parser to process the remote method call. |
||
136 | * |
||
137 | * @return \AppserverIo\RemoteMethodInvocation\RemoteMethodCallParser The parser instance |
||
138 | */ |
||
139 | public function getParser() |
||
143 | |||
144 | /** |
||
145 | * Sets the clients webapp name |
||
146 | * |
||
147 | * @param string $appName Name of the webapp using this client connection |
||
148 | * |
||
149 | * @return void |
||
150 | */ |
||
151 | 1 | public function injectAppName($appName) |
|
155 | |||
156 | /** |
||
157 | * Returns the name of the webapp this connection is for |
||
158 | * |
||
159 | * @return string The webapp name |
||
160 | */ |
||
161 | 1 | public function getAppName() |
|
165 | |||
166 | /** |
||
167 | * Sets the servers IP address for the client to connect to. |
||
168 | * |
||
169 | * @param string $address The servers IP address to connect to |
||
170 | * |
||
171 | * @return void |
||
172 | */ |
||
173 | 1 | public function injectAddress($address) |
|
177 | |||
178 | /** |
||
179 | * Returns the client sockets IP address. |
||
180 | * |
||
181 | * @return string |
||
182 | */ |
||
183 | 1 | public function getAddress() |
|
187 | |||
188 | /** |
||
189 | * Sets the servers port for the client to connect to. |
||
190 | * |
||
191 | * @param integer $port The servers port to connect to |
||
192 | * |
||
193 | * @return void |
||
194 | */ |
||
195 | 1 | public function injectPort($port) |
|
199 | |||
200 | /** |
||
201 | * Returns the client port. |
||
202 | * |
||
203 | * @return integer The client port |
||
204 | */ |
||
205 | 1 | public function getPort() |
|
209 | |||
210 | /** |
||
211 | * Sets the transport to use. |
||
212 | * |
||
213 | * @param integer $transport The transport to use |
||
214 | * |
||
215 | * @return void |
||
216 | */ |
||
217 | public function injectTransport($transport) |
||
221 | |||
222 | /** |
||
223 | * Returns the transport to use. |
||
224 | * |
||
225 | * @return integer The transport to use. |
||
226 | */ |
||
227 | public function getTransport() |
||
231 | |||
232 | /** |
||
233 | * Creates the connection to the container. |
||
234 | * |
||
235 | * @return void |
||
236 | */ |
||
237 | public function connect() |
||
241 | |||
242 | /** |
||
243 | * Shutdown the connection to the container. |
||
244 | * |
||
245 | * @return void |
||
246 | */ |
||
247 | public function disconnect() |
||
251 | |||
252 | /** |
||
253 | * Returns the socket the connection is based on. |
||
254 | * |
||
255 | * @return object|null The socket instance |
||
256 | */ |
||
257 | public function getSocket() |
||
261 | |||
262 | /** |
||
263 | * Sends the remote method call to the container instance. |
||
264 | * |
||
265 | * @param \AppserverIo\RemoteMethodInvocation\RemoteMethodInterface $remoteMethod The remote method instance |
||
266 | * |
||
267 | * @return mixed The response from the container |
||
268 | * @see \AppserverIo\RemoteMethodInvocation\ConnectionInterface::send() |
||
269 | * |
||
270 | * @throws \Exception Is thrown, if the remote method call cannot be invoked |
||
271 | */ |
||
272 | public function send(RemoteMethodInterface $remoteMethod) |
||
318 | |||
319 | /** |
||
320 | * Prepares path for the connection to the persistence container. |
||
321 | * |
||
322 | * @return string The path to define the persistence container module |
||
323 | */ |
||
324 | protected function getPath() |
||
328 | |||
329 | /** |
||
330 | * Prepares the base URL we used for the connection to the persistence container. |
||
331 | * |
||
332 | * @param string $path The URL path to append |
||
333 | * |
||
334 | * @return string The default base URL |
||
335 | */ |
||
336 | protected function getBaseUrl($path = '') |
||
341 | |||
342 | /** |
||
343 | * Initializes a new session instance. |
||
344 | * |
||
345 | * @return \AppserverIo\RemoteMethodInvocation\SessionInterface The session instance |
||
346 | * @see \AppserverIo\RemoteMethodInvocation\ConnectionInterface::createContextSession() |
||
347 | */ |
||
348 | public function createContextSession() |
||
353 | |||
354 | /** |
||
355 | * Returns the application instance. |
||
356 | * |
||
357 | * @return \AppserverIo\Psr\Application\ApplicationInterface|null The application instance |
||
358 | */ |
||
359 | public function getApplication() |
||
363 | } |
||
364 |
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.