| @@ 169-179 (lines=11) @@ | ||
| 166 | ->latest('created_at') |
|
| 167 | ->first(); |
|
| 168 | ||
| 169 | $loop->addTimer($timeout, function () use ($gitter, $lastMessage) { |
|
| 170 | $gitter->getMessages($lastMessage->gitter_id, GitterRoom::MESSAGE_FETCH_ASC) |
|
| 171 | ->fetch(function (GitterMessage $message, Controls $controls) { |
|
| 172 | $this->onMessage($message); |
|
| 173 | $controls->next(); |
|
| 174 | }) |
|
| 175 | ->then(function () use ($gitter) { |
|
| 176 | $this->warn('Connection...'); |
|
| 177 | $this->listen($gitter); |
|
| 178 | }); |
|
| 179 | }); |
|
| 180 | } |
|
| 181 | ||
| 182 | /** |
|
| @@ 101-114 (lines=14) @@ | ||
| 98 | /** |
|
| 99 | * @param GitterRoom $room |
|
| 100 | */ |
|
| 101 | public function syncMessages(GitterRoom $room) |
|
| 102 | { |
|
| 103 | /** @var CircleProgress $circle */ |
|
| 104 | $this->output->writeln('Fetching...'); |
|
| 105 | ||
| 106 | $room->getMessages() |
|
| 107 | // Fetch all messages |
|
| 108 | ->fetch(function (GitterMessage $message, Controls $controls) { |
|
| 109 | $this->messageRemember($message, $controls); |
|
| 110 | }) |
|
| 111 | ->then(function () use ($room) { |
|
| 112 | $this->syncLatestMessages($room); |
|
| 113 | }); |
|
| 114 | } |
|
| 115 | ||
| 116 | /** |
|
| 117 | * @param GitterMessage $gitterMessage |
|