Search in sources :

Example 1 with AudioWebSocketAdapter

use of org.javacord.core.util.gateway.AudioWebSocketAdapter in project Javacord by BtoBastian.

the class AudioConnectionImpl method tryConnect.

/**
 * Tries to establish a connection if all required information is available and there's not already a connection.
 *
 * @return Whether it will try to connect or not.
 */
public synchronized boolean tryConnect() {
    if (movingFuture != null && !movingFuture.isDone()) {
        movingFuture.complete(null);
        return true;
    }
    if (connectingOrConnected || sessionId == null || token == null || endpoint == null) {
        return false;
    }
    connectingOrConnected = true;
    logger.debug("Received all information required to connect to voice channel {}", getChannel());
    websocketAdapter = new AudioWebSocketAdapter(this);
    channel = channel.getCurrentCachedInstance().flatMap(Channel::asServerVoiceChannel).orElse(channel);
    return true;
}
Also used : Channel(org.javacord.api.entity.channel.Channel) ServerVoiceChannel(org.javacord.api.entity.channel.ServerVoiceChannel) AudioWebSocketAdapter(org.javacord.core.util.gateway.AudioWebSocketAdapter)

Aggregations

Channel (org.javacord.api.entity.channel.Channel)1 ServerVoiceChannel (org.javacord.api.entity.channel.ServerVoiceChannel)1 AudioWebSocketAdapter (org.javacord.core.util.gateway.AudioWebSocketAdapter)1