reconnect on failure
This commit is contained in:
parent
db0c87ac05
commit
44b3476eb1
|
@ -15,7 +15,7 @@ private[relay] final class FICS(config: FICS.Config) extends Actor with Stash wi
|
||||||
|
|
||||||
var send: String => Unit = _
|
var send: String => Unit = _
|
||||||
|
|
||||||
val telnet = context.actorOf(Props(classOf[Telnet], config.remote, self), name = "telnet")
|
val telnet = context.actorOf(Props(classOf[Telnet], () => config.remote, self), name = "telnet")
|
||||||
|
|
||||||
startWith(Connect, none)
|
startWith(Connect, none)
|
||||||
|
|
||||||
|
|
|
@ -6,13 +6,13 @@ import akka.util.ByteString
|
||||||
import java.net.InetSocketAddress
|
import java.net.InetSocketAddress
|
||||||
|
|
||||||
private[relay] final class Telnet(
|
private[relay] final class Telnet(
|
||||||
remote: InetSocketAddress,
|
remote: () => InetSocketAddress,
|
||||||
listener: ActorRef) extends Actor {
|
listener: ActorRef) extends Actor {
|
||||||
|
|
||||||
import Tcp._
|
import Tcp._
|
||||||
import context.system
|
import context.system
|
||||||
|
|
||||||
IO(Tcp) ! Connect(remote, options = List(
|
IO(Tcp) ! Connect(remote(), options = List(
|
||||||
SO.TcpNoDelay(false)
|
SO.TcpNoDelay(false)
|
||||||
))
|
))
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ private[relay] final class Telnet(
|
||||||
listener ! "connect failed"
|
listener ! "connect failed"
|
||||||
context stop self
|
context stop self
|
||||||
|
|
||||||
case Connected(remote, local) =>
|
case Connected(_, local) =>
|
||||||
val connection = sender()
|
val connection = sender()
|
||||||
connection ! Register(self)
|
connection ! Register(self)
|
||||||
listener ! Telnet.Connection({ str =>
|
listener ! Telnet.Connection({ str =>
|
||||||
|
@ -52,8 +52,7 @@ private[relay] final class Telnet(
|
||||||
case "close" =>
|
case "close" =>
|
||||||
connection ! Close
|
connection ! Close
|
||||||
case _: ConnectionClosed =>
|
case _: ConnectionClosed =>
|
||||||
listener ! Telnet.Close
|
sys error "Telnet connection has closed!"
|
||||||
context stop self
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -68,5 +67,4 @@ object Telnet {
|
||||||
case class BufferUntil(str: Option[String])
|
case class BufferUntil(str: Option[String])
|
||||||
case object ConnectFailed
|
case object ConnectFailed
|
||||||
case object WriteFailed
|
case object WriteFailed
|
||||||
case object Close
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue