1 | <?php |
||
42 | class Response extends Message |
||
43 | { |
||
44 | |||
45 | /** |
||
46 | * The last response for a request. |
||
47 | */ |
||
48 | const TYPE_FINAL = '!done'; |
||
49 | |||
50 | /** |
||
51 | * A response with data. |
||
52 | */ |
||
53 | const TYPE_DATA = '!re'; |
||
54 | |||
55 | /** |
||
56 | * A response signifying error. |
||
57 | */ |
||
58 | const TYPE_ERROR = '!trap'; |
||
59 | |||
60 | /** |
||
61 | * A response signifying a fatal error, due to which the connection would be |
||
62 | * terminated. |
||
63 | */ |
||
64 | const TYPE_FATAL = '!fatal'; |
||
65 | |||
66 | /** |
||
67 | * An array of unrecognized words in network order. |
||
68 | * |
||
69 | * @var string[] |
||
70 | */ |
||
71 | protected $unrecognizedWords = array(); |
||
72 | |||
73 | /** |
||
74 | * The response type. |
||
75 | * |
||
76 | * @var string |
||
77 | */ |
||
78 | private $_type; |
||
79 | |||
80 | /** |
||
81 | * Extracts a new response from a communicator. |
||
82 | * |
||
83 | * @param Communicator $com The communicator from which to extract |
||
84 | * the new response. |
||
85 | * @param int|null $streamOn Threshold after which to stream |
||
86 | * a word. NULL to disable streaming altogether. |
||
87 | * @param int $sTimeout If a response is not immediately |
||
88 | * available, wait this many seconds. If NULL, wait indefinitely. |
||
89 | * @param int|null $usTimeout Microseconds to add to the waiting time. |
||
90 | * @param Registry|null $reg An optional registry to sync the |
||
91 | * response with. |
||
92 | * |
||
93 | * @see getType() |
||
94 | * @see getArgument() |
||
95 | */ |
||
96 | public function __construct( |
||
160 | |||
161 | /** |
||
162 | * Extracts a new response from a communicator. |
||
163 | * |
||
164 | * This is the function that performs the actual receiving, while the |
||
165 | * constructor is also involved in locks and registry sync. |
||
166 | * |
||
167 | * @param Communicator $com The communicator from which to extract |
||
168 | * the new response. |
||
169 | * @param int|null $streamOn Threshold after which to stream |
||
170 | * a word. NULL to disable streaming altogether. |
||
171 | * @param int $sTimeout If a response is not immediately |
||
172 | * available, wait this many seconds. If NULL, wait indefinitely. |
||
173 | * Note that if an empty sentence is received, the timeout will be |
||
174 | * reset for another sentence receiving. |
||
175 | * @param int|null $usTimeout Microseconds to add to the waiting time. |
||
176 | * |
||
177 | * @return void |
||
178 | */ |
||
179 | private function _receive( |
||
252 | |||
253 | /** |
||
254 | * Sets the response type. |
||
255 | * |
||
256 | * Sets the response type. Valid values are the TYPE_* constants. |
||
257 | * |
||
258 | * @param string $type The new response type. |
||
259 | * |
||
260 | * @return $this The response object. |
||
261 | * |
||
262 | * @see getType() |
||
263 | */ |
||
264 | protected function setType($type) |
||
282 | |||
283 | /** |
||
284 | * Gets the response type. |
||
285 | * |
||
286 | * @return string The response type. |
||
287 | * |
||
288 | * @see setType() |
||
289 | */ |
||
290 | public function getType() |
||
294 | |||
295 | /** |
||
296 | * Gets the value of an argument. |
||
297 | * |
||
298 | * @param string $name The name of the argument. |
||
299 | * |
||
300 | * @return string|resource|null The value of the specified argument. |
||
301 | * Returns NULL if such an argument is not set. |
||
302 | * |
||
303 | * @deprecated 1.0.0b5 Use {@link static::getProperty()} instead. |
||
304 | * This method will be removed upon final release, and is currently |
||
305 | * left standing merely because it can't be easily search&replaced in |
||
306 | * existing code, due to the fact the name "getArgument()" is shared |
||
307 | * with {@link Request::getArgument()}, which is still valid. |
||
308 | * @codeCoverageIgnore |
||
309 | */ |
||
310 | public function getArgument($name) |
||
320 | |||
321 | /** |
||
322 | * Gets the value of a property. |
||
323 | * |
||
324 | * @param string $name The name of the property. |
||
325 | * |
||
326 | * @return string|resource|null The value of the specified property. |
||
327 | * Returns NULL if such a property is not set. |
||
328 | */ |
||
329 | public function getProperty($name) |
||
333 | |||
334 | /** |
||
335 | * Gets a list of unrecognized words. |
||
336 | * |
||
337 | * @return string[] The list of unrecognized words. |
||
338 | */ |
||
339 | public function getUnrecognizedWords() |
||
343 | } |
||
344 |