Skip to content
Permalink
Browse files

Better WebSocketClient cross-platform accessibility

  • Loading branch information...
darkfrog26 committed Oct 3, 2019
1 parent 8585dfd commit 8b89c22b17d7eba206173b88078036f59c1bd8d5
@@ -0,0 +1,24 @@
package io.youi.client

import io.youi.http.{Connection, WebSocketUtil}
import io.youi.net.URL
import org.scalajs.dom.WebSocket

import scala.concurrent.Future
import scribe.Execution.global

class WebSocketClient(url: URL) extends Connection(client = true) {
private lazy val webSocket: WebSocket = WebSocketUtil.connect(url, this)

def connect(): Future[Unit] = {
webSocket
connected.future(b => b).map(_ => ())
}

def disconnect(): Unit = {
webSocket.close()
_connected @= false
}

def dispose(): Unit = disconnect()
}
@@ -1,8 +1,8 @@
package io.youi.example

import com.outr.hookup.{Hookup, HookupSupport}
import io.youi.client.WebSocketClient
import io.youi.net.URL
import io.youi.server.WebSocketClient
import io.youi.util.Time

import scala.concurrent.{Await, Future}
@@ -1,27 +1,27 @@
package io.youi.server
package io.youi.client

import java.io.IOException
import java.net.URI
import java.nio.ByteBuffer

import reactify.Var
import io.undertow.protocols.ssl.UndertowXnioSsl
import io.undertow.server.DefaultByteBufferPool
import io.undertow.util.Headers
import io.undertow.websockets.client.WebSocketClient.ConnectionBuilder
import io.undertow.websockets.client.{WebSocketClientNegotiation, WebSocketClient => UndertowWebSocketClient}
import io.undertow.websockets.core.{AbstractReceiveListener, BufferedTextMessage, WebSocketCallback, WebSocketChannel, WebSockets}
import io.undertow.websockets.core._
import io.youi.http.Connection
import io.youi.net.URL
import io.youi.server.KeyStore
import io.youi.server.util.SSLUtil
import io.youi.util.Time
import org.xnio.{IoFuture, OptionMap, Options, Xnio}

import scala.jdk.CollectionConverters._
import scala.concurrent.duration._
import reactify.Var
import scribe.Execution.global

import scala.concurrent.duration._
import scala.concurrent.{Future, Promise}
import scala.jdk.CollectionConverters._

class WebSocketClient(url: URL,
keyStore: Option[KeyStore] = None,

0 comments on commit 8b89c22

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