X-Git-Url: https://git.distorted.org.uk/~mdw/tripe-android/blobdiff_plain/9190adc66f814b8b9add2d2df2ff65b43175104b..0157de026e802e94a2d0db0421b02ffca986c616:/admin.scala diff --git a/admin.scala b/admin.scala index 52a2912..321fb56 100644 --- a/admin.scala +++ b/admin.scala @@ -30,7 +30,7 @@ package uk.org.distorted.tripe; package object admin { import java.io.{BufferedReader, InputStreamReader, OutputStreamWriter}; import java.util.concurrent.locks.{Condition, ReentrantLock => Lock}; -import scala.collection.mutable.{HashMap, Publisher}; +import scala.collection.mutable.HashMap; import scala.concurrent.Channel; import scala.util.control.Breaks; @@ -78,7 +78,7 @@ class CommandFailed(val msg: Seq[String]) extends Exception { class ConnectionLostException extends Exception; -object Connection extends Publisher[AsyncMessage] +object Connection extends Hook[AsyncMessage] { /* Synchronization. * @@ -102,7 +102,7 @@ object Connection extends Publisher[AsyncMessage] private[this] var nextmsg: Option[JobMessage] = None; private[this] def fetchNext() - { if (nextmsg == None) nextmsg = Some(ch.read); } + { if (!nextmsg) nextmsg = Some(ch.read); } override def hasNext: Boolean = { fetchNext(); nextmsg match { @@ -114,9 +114,9 @@ object Connection extends Publisher[AsyncMessage] fetchNext(); nextmsg match { case None => ??? - case Some(JobOK) => throw new NoSuchElementException - case Some(JobFail(msg)) => throw new CommandFailed(msg) - case Some(JobLostConnection) => throw new ConnectionLostException + case Some(JobOK) => throw new NoSuchElementException; + case Some(JobFail(msg)) => throw new CommandFailed(msg); + case Some(JobLostConnection) => throw new ConnectionLostException; case Some(JobInfo(msg)) => nextmsg = None; msg } } @@ -248,7 +248,7 @@ println(s";; line: $line"); j } case msg: AsyncMessage => - publish(msg); + callHook(msg); case _: ServiceMessage => ok; } @@ -267,7 +267,7 @@ println(s";; line: $line"); case None => ok; } } - publish(ConnectionLost); + callHook(ConnectionLost); } } }