Skip to content

Commit

Permalink
Fix player is not playing after move between vc or changing regions (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Walkyst authored Dec 13, 2021
1 parent 54a16b4 commit 8e1010a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class SocketContext internal constructor(
private var session: WebSocketSession,
private val socketServer: SocketServer,
val userId: String,
private val koe: KoeClient
val koe: KoeClient
) {

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,14 @@ class WebSocketHandlers(private val contextMap: Map<String, SocketContext>) {

//discord sometimes send a partial server update missing the endpoint, which can be ignored.
endpoint ?: return
//clear old connection
context.koe.destroyConnection(guildId)

val player = context.getPlayer(guildId)
val conn = context.getVoiceConnection(player)
conn.connect(VoiceServerInfo(sessionId, endpoint, token))
player.provideTo(conn)
conn.connect(VoiceServerInfo(sessionId, endpoint, token)).whenComplete { _, _ ->
player.provideTo(conn)
}
}

fun play(context: SocketContext, json: JSONObject) {
Expand Down

0 comments on commit 8e1010a

Please sign in to comment.