35 $this->channels = array();
37 $transport->setHandler(
39 \
fpoirotte\Pssht\Messages\CHANNEL\OPEN::getMessageId(),
40 new \
fpoirotte\Pssht\Handlers\CHANNEL\OPEN($this)
43 \
fpoirotte\Pssht\Messages\CHANNEL\CLOSE::getMessageId(),
44 new \
fpoirotte\Pssht\Handlers\CHANNEL\CLOSE($this)
48 new \
fpoirotte\Pssht\Handlers\CHANNEL\REQUEST($this)
51 foreach (array_merge(range(91, 96), array(99, 100)) as $msgId) {
52 $transport->setHandler($msgId, $this);
62 $localChannel = $decoder->decodeUint32();
63 $encoder = new \fpoirotte\Pssht\Wire\Encoder();
64 $encoder->encodeUint32($localChannel);
65 $decoder->getBuffer()->unget($encoder->getBuffer()->get(0));
67 if (isset($this->handlers[$localChannel][$msgType])) {
68 $handler = $this->handlers[$localChannel][$msgType];
69 $logging = \Plop\Plop::getInstance();
71 'Calling %(handler)s for channel #%(channel)d ' .
72 'with message type #%(msgType)d',
74 'handler' => get_class($handler) .
'::handle',
75 'channel' => $localChannel,
76 'msgType' => $msgType,
79 return $handler->handle($msgType, $decoder, $transport, $context);
95 for ($i = 0; isset($this->channels[$i]); ++$i) {
98 $this->channels[$i] = $message->getChannel();
99 $this->handlers[$i] = array();
115 throw new \InvalidArgumentException();
118 unset($this->channels[$id]);
119 unset($this->handlers[$id]);
134 if (is_int($message)) {
135 return $this->channels[$message];
137 return $this->channels[$message->getChannel()];
155 \
fpoirotte\Pssht\Handlers\HandlerInterface $handler
157 if (!is_int($type) || $type < 0 || $type > 255) {
158 throw new \InvalidArgumentException();
161 if (!is_int($message)) {
162 if (!($message instanceof \
fpoirotte\Pssht\Messages\CHANNEL\REQUEST\
Base)) {
163 throw new \InvalidArgumentException();
165 $message = $message->getChannel();
168 $this->handlers[$message][$type] = $handler;
187 \
fpoirotte\Pssht\Handlers\HandlerInterface $handler
189 if (!is_int($type) || $type < 0 || $type > 255) {
190 throw new \InvalidArgumentException();
193 if (!is_int($message)) {
194 if (!($message instanceof \
fpoirotte\Pssht\Messages\CHANNEL\REQUEST\
Base)) {
195 throw new \InvalidArgumentException();
197 $message = $message->getChannel();
200 if (isset($this->handlers[$message][$type]) &&
201 $this->handlers[$message][$type] === $handler) {
202 unset($this->handlers[$message][$type]);
__construct(\fpoirotte\Pssht\Transport $transport)
allocateChannel(\fpoirotte\Pssht\Messages\CHANNEL\OPEN $message)
setHandler($message, $type,\fpoirotte\Pssht\Handlers\HandlerInterface $handler)
handle($msgType,\fpoirotte\Pssht\Wire\Decoder $decoder,\fpoirotte\Pssht\Transport $transport, array &$context)
$channels
Opened SSH channels.
unsetHandler($message, $type,\fpoirotte\Pssht\Handlers\HandlerInterface $handler)