1 | <?php |
||
23 | class TelnetClient implements TelnetClientInterface |
||
24 | { |
||
25 | /** |
||
26 | * @var SocketFactory |
||
27 | */ |
||
28 | protected $socketFactory; |
||
29 | |||
30 | /** |
||
31 | * @var PromptMatcherInterface |
||
32 | */ |
||
33 | protected $promptMatcher; |
||
34 | |||
35 | /** |
||
36 | * @var InterpretAsCommand |
||
37 | */ |
||
38 | protected $interpretAsCommand; |
||
39 | |||
40 | /** |
||
41 | * @var string |
||
42 | */ |
||
43 | protected $prompt = '\$'; |
||
44 | |||
45 | /** |
||
46 | * @var string |
||
47 | */ |
||
48 | protected $promptError = 'ERROR'; |
||
49 | |||
50 | /** |
||
51 | * @var string |
||
52 | */ |
||
53 | protected $lineEnding = "\n"; |
||
54 | |||
55 | /** |
||
56 | * @var int |
||
57 | */ |
||
58 | protected $maxBytesRead = 0; |
||
59 | |||
60 | /** |
||
61 | * @var Socket |
||
62 | */ |
||
63 | protected $socket; |
||
64 | |||
65 | /** |
||
66 | * @var string |
||
67 | */ |
||
68 | protected $buffer; |
||
69 | |||
70 | /** |
||
71 | * @var string |
||
72 | */ |
||
73 | protected $NULL; |
||
74 | |||
75 | /** |
||
76 | * @var string |
||
77 | */ |
||
78 | protected $DC1; |
||
79 | |||
80 | /** |
||
81 | * @var string |
||
82 | */ |
||
83 | protected $IAC; |
||
84 | |||
85 | 18 | /** |
|
86 | * @param SocketFactory $socketFactory |
||
87 | * @param PromptMatcherInterface $promptMatcher |
||
88 | * @param InterpretAsCommand $interpretAsCommand |
||
89 | */ |
||
90 | 18 | public function __construct( |
|
102 | |||
103 | /** |
||
104 | * @param string $dsn |
||
105 | * @param string $prompt |
||
106 | * @param string $promptError |
||
107 | 17 | * @param string $lineEnding |
|
108 | * @param float|null $timeout |
||
109 | 17 | * |
|
110 | 4 | * @throws TelnetExceptionInterface |
|
111 | 4 | */ |
|
112 | public function connect($dsn, $prompt = null, $promptError = null, $lineEnding = null, $timeout = null) |
||
134 | |||
135 | 2 | /** |
|
136 | 2 | * @param string $prompt |
|
137 | */ |
||
138 | public function setPrompt($prompt) |
||
142 | |||
143 | 1 | /** |
|
144 | 1 | * @param string $promptError |
|
145 | */ |
||
146 | public function setPromptError($promptError) |
||
150 | |||
151 | 14 | /** |
|
152 | 14 | * @param string $lineEnding |
|
153 | */ |
||
154 | public function setLineEnding($lineEnding) |
||
158 | |||
159 | 19 | /** |
|
160 | 19 | * Set the maximum number of bytes that can be read per request |
|
161 | * |
||
162 | * @param int $maxBytesRead |
||
163 | */ |
||
164 | public function setMaxBytesRead($maxBytesRead) |
||
165 | { |
||
166 | $this->maxBytesRead = $maxBytesRead; |
||
167 | } |
||
168 | |||
169 | /** |
||
170 | * @param Socket $socket |
||
171 | */ |
||
172 | public function setSocket(Socket $socket) |
||
176 | 1 | ||
177 | /** |
||
178 | * @return Socket |
||
179 | 3 | */ |
|
180 | 3 | public function getSocket() |
|
184 | |||
185 | /** |
||
186 | * @param float $timeout |
||
187 | */ |
||
188 | public function setReadTimeout($timeout) |
||
199 | 15 | ||
200 | /** |
||
201 | * @param string $command |
||
202 | * @param string $prompt |
||
203 | * @param string $promptError |
||
204 | * |
||
205 | * @return TelnetResponseInterface |
||
206 | */ |
||
207 | public function execute($command, $prompt = null, $promptError = null) |
||
216 | |||
217 | /** |
||
218 | * @param string $command |
||
219 | * |
||
220 | * @return void |
||
221 | * @throws TelnetExceptionInterface |
||
222 | */ |
||
223 | protected function write($command) |
||
231 | 15 | ||
232 | 15 | /** |
|
233 | 1 | * @param string $prompt |
|
234 | * @param string $promptError |
||
235 | * |
||
236 | 14 | * @return TelnetResponseInterface |
|
237 | * @throws TelnetExceptionInterface |
||
238 | */ |
||
239 | protected function getResponse($prompt = null, $promptError = null) |
||
290 | |||
291 | /** |
||
292 | * @return TelnetClientInterface |
||
293 | */ |
||
294 | public static function factory() |
||
302 | |||
303 | public function __destruct() |
||
311 | } |
||
312 |