From 39d51e36cd5f2058966dd6200609d8fb9dac92ec Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Sun, 13 Oct 2019 18:06:51 +0800 Subject: avoid redundantly completing promise in WsClient connection failure --- cask/util/src/cask/util/WsClient.scala | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/cask/util/src/cask/util/WsClient.scala b/cask/util/src/cask/util/WsClient.scala index f15d7df..152ab3b 100644 --- a/cask/util/src/cask/util/WsClient.scala +++ b/cask/util/src/cask/util/WsClient.scala @@ -4,7 +4,6 @@ import scala.concurrent.duration.Duration import scala.concurrent.{Await, ExecutionContext, Promise} class WsClient(impl: WebsocketBase) - (f: PartialFunction[cask.util.Ws.Event, Unit]) (implicit ec: ExecutionContext, log: Logger) extends cask.util.BatchActor[Ws.Event]{ @@ -33,7 +32,7 @@ object WsClient{ val p = Promise[WsClient] val impl = new WebsocketClientImpl(url) { def onOpen() = { - if (!p.isCompleted) p.success(new WsClient(this)(f)) + if (!p.isCompleted) p.success(new WsClient(this)) } def onMessage(message: String) = { receiveActor.send(Ws.Text(message)) @@ -43,7 +42,6 @@ object WsClient{ } def onClose(code: Int, reason: String) = { receiveActor.send(Ws.Close(code, reason)) - if (!p.isCompleted) p.success(new WsClient(this)(f)) } def onError(ex: Exception): Unit = { receiveActor.send(Ws.Error(ex)) -- cgit v1.2.3