Skip to content

Commit 4716574

Browse files
committed
handleHello
1 parent 09e5e5f commit 4716574

1 file changed

Lines changed: 15 additions & 8 deletions

File tree

  • src/Discord/Voice/Client

src/Discord/Voice/Client/WS.php

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -206,14 +206,6 @@ public function handleConnection(WebSocket $ws): void
206206
//$this->handleUndocumented($data);
207207

208208
switch ($data->op) {
209-
case Op::VOICE_HELLO:
210-
$this->hbInterval = $this->vc->heartbeatInterval = $data->d->heartbeat_interval;
211-
$this->sendHeartbeat();
212-
$this->heartbeat = $this->discord->loop->addPeriodicTimer(
213-
$this->hbInterval / 1000,
214-
fn () => $this->sendHeartbeat()
215-
);
216-
break;
217209
case Op::VOICE_CLIENT_CONNECT:
218210
$this->discord->logger->debug('received clients connected packet', ['data' => json_decode(json_encode($data->d), true)]);
219211
# "d" contains an array with ['user_ids' => array<string>]
@@ -379,6 +371,21 @@ public function handleHeartbeatAck(Payload $data): void
379371
$this->vc->emit('ws-heartbeat-ack', [$data->d->t]);
380372
}
381373

374+
/**
375+
* Handles the "Hello" event from the Discord voice server.
376+
*
377+
* @param Payload $data
378+
*/
379+
protected function handleHello(Payload $data): void
380+
{
381+
$this->hbInterval = $this->vc->heartbeatInterval = $data->d->heartbeat_interval;
382+
$this->sendHeartbeat();
383+
$this->heartbeat = $this->discord->loop->addPeriodicTimer(
384+
$this->hbInterval / 1000,
385+
fn () => $this->sendHeartbeat()
386+
);
387+
}
388+
382389
protected function handleDavePrepareTransition($data): void
383390
{
384391
$this->discord->logger->debug('DAVE Prepare Transition', ['data' => $data]);

0 commit comments

Comments
 (0)