| @@ 54-78 (lines=25) @@ | ||
| 51 | ); |
|
| 52 | } |
|
| 53 | ||
| 54 | public function close(FrameChannel $channel, Close $command): Frame |
|
| 55 | { |
|
| 56 | $replyCode = 0; |
|
| 57 | $replyText = ''; |
|
| 58 | $method = new Method(0, 0); |
|
| 59 | ||
| 60 | if ($command->hasReply()) { |
|
| 61 | $replyCode = $command->replyCode(); |
|
| 62 | $replyText = $command->replyText(); |
|
| 63 | } |
|
| 64 | ||
| 65 | if ($command->causedKnown()) { |
|
| 66 | $method = Methods::get($command->cause()); |
|
| 67 | } |
|
| 68 | ||
| 69 | return new Frame( |
|
| 70 | Type::method(), |
|
| 71 | $channel, |
|
| 72 | Methods::get('channel.close'), |
|
| 73 | new UnsignedShortInteger(new Integer($replyCode)), |
|
| 74 | new ShortString(new Str($replyText)), |
|
| 75 | new UnsignedShortInteger(new Integer($method->class())), |
|
| 76 | new UnsignedShortInteger(new Integer($method->method())) |
|
| 77 | ); |
|
| 78 | } |
|
| 79 | ||
| 80 | public function closeOk(FrameChannel $channel): Frame |
|
| 81 | { |
|
| @@ 106-130 (lines=25) @@ | ||
| 103 | ); |
|
| 104 | } |
|
| 105 | ||
| 106 | public function close(Close $command): Frame |
|
| 107 | { |
|
| 108 | $replyCode = 0; |
|
| 109 | $replyText = ''; |
|
| 110 | $method = new Method(0, 0); |
|
| 111 | ||
| 112 | if ($command->hasReply()) { |
|
| 113 | $replyCode = $command->replyCode(); |
|
| 114 | $replyText = $command->replyText(); |
|
| 115 | } |
|
| 116 | ||
| 117 | if ($command->causedKnown()) { |
|
| 118 | $method = Methods::get($command->cause()); |
|
| 119 | } |
|
| 120 | ||
| 121 | return new Frame( |
|
| 122 | Type::method(), |
|
| 123 | new Channel(0), |
|
| 124 | Methods::get('connection.close'), |
|
| 125 | new UnsignedShortInteger(new Integer($replyCode)), |
|
| 126 | new ShortString(new Str($replyText)), |
|
| 127 | new UnsignedShortInteger(new Integer($method->class())), |
|
| 128 | new UnsignedShortInteger(new Integer($method->method())) |
|
| 129 | ); |
|
| 130 | } |
|
| 131 | ||
| 132 | public function closeOk(): Frame |
|
| 133 | { |
|