Skip to content
Permalink
Browse files

Exposed ConnectionManager.removeConnection and better handling of `Ke…

…y.get`
  • Loading branch information
darkfrog26 committed Nov 19, 2019
1 parent abd8186 commit 538a2bad2fafa90398900312689ee30428531c89
@@ -39,7 +39,7 @@ class ConnectionManager[C <: Connection](app: ServerConnectedApplication[C]) {
_connections @= (connection :: _connections()).distinct
}

private def removeConnection(connection: C): Unit = synchronized {
def removeConnection(connection: C): Unit = synchronized {
_connections @= _connections.filterNot(_ eq connection)
connection.disconnect()
connection.queue.dispose()
@@ -4,7 +4,7 @@ import sbtcrossproject.CrossType

name := "youi"
organization in ThisBuild := "io.youi"
version in ThisBuild := "0.12.7"
version in ThisBuild := "0.12.8-SNAPSHOT"
scalaVersion in ThisBuild := "2.13.1"
crossScalaVersions in ThisBuild := List("2.13.1", "2.12.10")
resolvers in ThisBuild ++= Seq(
@@ -490,9 +490,13 @@ object Key {
map += key.value -> key
}

def get(value: String): Option[Key] = map.get(value)
def get(value: => String): Option[Key] = try {
map.get(value)
} catch {
case t: Throwable => None
}

def apply(value: String): Key = get(value).getOrElse(throw new RuntimeException(s"Unable to find Key for '$value'."))
def apply(value: => String): Key = get(value).getOrElse(Key.Unidentified)
}

case class KeyType private(name: String)

0 comments on commit 538a2ba

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