-
-
Notifications
You must be signed in to change notification settings - Fork 739
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changed audio connection requests (#457)
* New audio connection system to counter major race conditions * Remove connection requests from queue when guild is deleted * Fixed possible NPE on disconnect requests with no channels * Removed setDaemon from audio thread group * Added functionality to deal with possible racecondition related to moving a connection during it being opened.
- Loading branch information
1 parent
90653ee
commit 64b1b9f
Showing
11 changed files
with
386 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ src/test/ | |
# gradle | ||
/build/ | ||
/.gradle/ | ||
/out/ | ||
|
||
# eclipse files | ||
.classpath | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
src/main/java/net/dv8tion/jda/core/audio/ConnectionRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* Copyright 2015-2017 Austin Keener & Michael Ritter & Florian Spieß | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package net.dv8tion.jda.core.audio; | ||
|
||
import net.dv8tion.jda.core.entities.Guild; | ||
import net.dv8tion.jda.core.entities.VoiceChannel; | ||
|
||
public class ConnectionRequest | ||
{ | ||
protected final long guildId; | ||
protected long nextAttemptEpoch; | ||
protected ConnectionStage stage; | ||
protected VoiceChannel channel; | ||
|
||
public ConnectionRequest(Guild guild) | ||
{ | ||
this.stage = ConnectionStage.DISCONNECT; | ||
this.guildId = guild.getIdLong(); | ||
} | ||
|
||
public ConnectionRequest(VoiceChannel channel, ConnectionStage stage) | ||
{ | ||
this.channel = channel; | ||
this.guildId = channel.getGuild().getIdLong(); | ||
this.stage = stage; | ||
this.nextAttemptEpoch = System.currentTimeMillis(); | ||
} | ||
|
||
public void setStage(ConnectionStage stage) | ||
{ | ||
this.stage = stage; | ||
} | ||
|
||
public void setChannel(VoiceChannel channel) | ||
{ | ||
this.channel = channel; | ||
} | ||
|
||
public void setNextAttemptEpoch(long epochMillis) | ||
{ | ||
this.nextAttemptEpoch = epochMillis; | ||
} | ||
|
||
public VoiceChannel getChannel() | ||
{ | ||
return channel; | ||
} | ||
|
||
public ConnectionStage getStage() | ||
{ | ||
return stage; | ||
} | ||
|
||
public long getNextAttemptEpoch() | ||
{ | ||
return nextAttemptEpoch; | ||
} | ||
|
||
public long getGuildIdLong() | ||
{ | ||
return guildId; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/main/java/net/dv8tion/jda/core/audio/ConnectionStage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* Copyright 2015-2017 Austin Keener & Michael Ritter & Florian Spieß | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package net.dv8tion.jda.core.audio; | ||
|
||
public enum ConnectionStage | ||
{ | ||
CONNECT, RECONNECT, DISCONNECT | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.