In the Scala world, it is very important to be careful with the versions, as everything evolves quickly and back. Compatibility between major versions is not guaranteed.
.
1.3.1 Scala 2.10.3 Akka 2.3.0, Scala 2.11.1 Akka 2.3.2.
, Scala 2.10.3, Akka 2.3.0.
, , , , , .
, , , IO(Http) ! Http.Bind(...), . , Http.Bind, Http.Bound, , .
, - :
class MyApp extends Actor {
implicit val system = context.system
override def receive: Receive = {
case "start" =>
val myListener: ActorRef = system.actorOf(Props[TestHttpListener], "httpListener")
IO(Http) ! Http.Bind(myListener, interface = "localhost", port = 8080)
}
}
main() :
val myApp: ActorRef = system.actorOf(Props[MyApp], "myApp")
myApp ! "start"
, , , - , :
class TestHttpListener extends Actor {
def receive = {
case HttpRequest(HttpMethods.GET, Uri.Path("/ping"), _, _, _) =>
sender() ! HttpResponse(entity = "PONG")
case c : Tcp.Connected =>
sender() ! Http.Register(self)
}
}