【发布时间】:2014-02-10 12:56:26
【问题描述】:
在下面的代码中
GSM 模拟未绑定
永远不会记录,即使“禁用”消息已发送到服务器。如何正确解绑 akka tcp 服务器?
class GsmRouter extends Actor {
import Tcp._
import context.system
val name = this.getClass().getName()
val logger = LoggerFactory.getLogger(name)
def receive = {
case "enable" => IO(Tcp) ! Bind(self, ConfigurationUtils.gsmRouterAddress)
case "disable" => IO(Tcp) ! Unbind
case Unbound =>
logger.info("GSM mock unbound")
case Bound(localAddress) =>
logger.info("GSM mock bound to " + localAddress.getHostName() + ":" + localAddress.getPort())
case CommandFailed(Bind(_,localAddress: InetSocketAddress, _, _)) =>
logger.info("Could not bind to " + localAddress.getHostName() + ":" + localAddress.getPort())
context stop self
case Connected(remote, local) =>
logger.info("Client connected to GSM mock")
val handler = context.actorOf(Props[ConnectionHandler])
val connection = sender
connection ! Register(handler)
}
}
【问题讨论】: