Search in sources :

Example 1 with VoiceServerUpdateEventImpl

use of org.javacord.core.event.server.VoiceServerUpdateEventImpl in project Javacord by BtoBastian.

the class VoiceServerUpdateHandler method handle.

@Override
public void handle(JsonNode packet) {
    String token = packet.get("token").asText();
    String endpoint = packet.get("endpoint").asText();
    long serverId = packet.get("guild_id").asLong();
    // We need the session id to connect to an audio websocket
    AudioConnectionImpl pendingAudioConnection = api.getPendingAudioConnectionByServerId(serverId);
    if (pendingAudioConnection != null) {
        pendingAudioConnection.setToken(token);
        pendingAudioConnection.setEndpoint(endpoint);
        pendingAudioConnection.tryConnect();
    }
    api.getServerById(serverId).ifPresent(server -> {
        VoiceServerUpdateEvent event = new VoiceServerUpdateEventImpl(server, token, endpoint);
        api.getEventDispatcher().dispatchVoiceServerUpdateEvent((DispatchQueueSelector) server, server, event);
    });
}
Also used : VoiceServerUpdateEvent(org.javacord.api.event.server.VoiceServerUpdateEvent) VoiceServerUpdateEventImpl(org.javacord.core.event.server.VoiceServerUpdateEventImpl) AudioConnectionImpl(org.javacord.core.audio.AudioConnectionImpl)

Aggregations

VoiceServerUpdateEvent (org.javacord.api.event.server.VoiceServerUpdateEvent)1 AudioConnectionImpl (org.javacord.core.audio.AudioConnectionImpl)1 VoiceServerUpdateEventImpl (org.javacord.core.event.server.VoiceServerUpdateEventImpl)1