-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Correctly close zlib stream when gateway disconnects (#849)
- Loading branch information
1 parent
e643db9
commit 235ed1d
Showing
5 changed files
with
15 additions
and
3 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
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 |
---|---|---|
@@ -1,7 +1,8 @@ | ||
package dev.kord.gateway | ||
|
||
import io.ktor.utils.io.core.* | ||
import io.ktor.websocket.* | ||
|
||
internal expect class Inflater() { | ||
internal expect class Inflater() : Closeable { | ||
fun Frame.inflateData(): String | ||
} |
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 |
---|---|---|
@@ -1,16 +1,19 @@ | ||
package dev.kord.gateway | ||
|
||
import dev.kord.gateway.internal.Inflate | ||
import io.ktor.utils.io.core.* | ||
import io.ktor.websocket.* | ||
import node.buffer.Buffer | ||
import node.buffer.BufferEncoding | ||
|
||
internal actual class Inflater { | ||
internal actual class Inflater : Closeable { | ||
private val inflate = Inflate() | ||
|
||
actual fun Frame.inflateData(): String { | ||
val buffer = Buffer.from(data) | ||
|
||
return inflate.process(buffer).toString(BufferEncoding.utf8) | ||
} | ||
|
||
override fun close() = inflate.close() | ||
} |
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 |
---|---|---|
|
@@ -8,4 +8,6 @@ import node.buffer.Buffer | |
|
||
internal external class Inflate { | ||
fun process(data: Uint8Array): Buffer | ||
|
||
fun close() | ||
} |
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