Skip to content
Permalink
Browse files

Updated ClientConnectedApplication.communicationURL to support asynch…

…ronous loading
  • Loading branch information
darkfrog26 committed Oct 25, 2019
1 parent d12b740 commit 7a2eb17d56d17f8199cd53c9fd1e231e77e75be8
@@ -15,7 +15,7 @@ import scala.concurrent.duration._
import scala.scalajs.js.typedarray.{ArrayBuffer, TypedArrayBuffer}

trait ClientConnectedApplication[C <: Connection] extends ClientApplication with YouIConnectedApplication[C] {
def communicationURL: URL = {
def communicationURL: Future[URL] = Future.successful {
val protocol = if (baseURL.protocol == Protocol.Https) {
Protocol.Wss
} else {
@@ -50,8 +50,8 @@ trait ClientConnectedApplication[C <: Connection] extends ClientApplication with
}
}

def connect(): Future[ConnectionStatus] = {
val ws = new WebSocketClient(communicationURL)
def connect(): Future[ConnectionStatus] = communicationURL.flatMap { url =>
val ws = new WebSocketClient(url)
connection.webSocket @= Some(ws)
ws.connect()
}
@@ -57,7 +57,6 @@ trait Server extends HttpHandler with ErrorSupport {
def initialize(): Future[Unit] = {
val shouldInit = initialized.compareAndSet(false, true)
if (shouldInit) {
scribe.info("Init!")
init()
} else {
Future.successful(())

0 comments on commit 7a2eb17

Please sign in to comment.
You can’t perform that action at this time.