update WebSocketClient.kt

This commit is contained in:
tursom 2021-07-04 17:25:55 +08:00
parent aeda793a5d
commit 0cc94bf998

View File

@ -1,5 +1,6 @@
package cn.tursom.core.ws
import cn.tursom.core.ShutdownHook
import cn.tursom.core.buffer.ByteBuffer
import cn.tursom.core.buffer.impl.NettyByteBuffer
import io.netty.bootstrap.Bootstrap
@ -37,6 +38,12 @@ open class WebSocketClient(
var ch: Channel? = null
internal set
init {
ShutdownHook.addHook {
close()
}
}
fun open() {
close()
val scheme = if (uri.scheme == null) "ws" else uri.scheme