Commit 1f552daa by 王宇航

1.5.5

1.連接超時時間默認10秒
2.onClose方法錯誤內容為連接失敗時,不觸發onError方法
parent 02d2c28f
...@@ -55,7 +55,7 @@ afterEvaluate { ...@@ -55,7 +55,7 @@ afterEvaluate {
groupId = "com.gingersoft.connect" groupId = "com.gingersoft.connect"
artifactId = "Connect" artifactId = "Connect"
version = "1.5.4" version = "1.5.5"
// 添加 POM 配置 // 添加 POM 配置
// pom { // pom {
// name.set("GingerSoftConnect") // name.set("GingerSoftConnect")
......
...@@ -10,7 +10,7 @@ class GingerSoftConnect { ...@@ -10,7 +10,7 @@ class GingerSoftConnect {
fun connect( fun connect(
ip: String, ip: String,
port: Int, port: Int,
connectOutTime: Int = 10, connectOutTime: Int = 10000,
listener: SocketStateListener? listener: SocketStateListener?
): MessageBuilder { ): MessageBuilder {
val uri = URI("ws://$ip:$port") val uri = URI("ws://$ip:$port")
......
...@@ -41,13 +41,14 @@ class MyWebSocketClient( ...@@ -41,13 +41,14 @@ class MyWebSocketClient(
} }
override fun onClose(code: Int, reason: String?, remote: Boolean) { override fun onClose(code: Int, reason: String?, remote: Boolean) {
status = if(reason!=null && reason.contains("failed to connect")){ // = if(reason!=null && reason.contains("failed to connect")){
onError(ConnectException(reason)) // onError(ConnectException(reason))
3 // 3
} else { // } else {
listener?.onClose(code, reason, remote) listener?.onClose(code, reason, remote)
2 status = 2
} // 2
// }
} }
override fun onError(ex: Exception?) { override fun onError(ex: Exception?) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment