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;
}
Aggregations