package com.czechscala.blank | |
import akka.actor._ | |
class AkkaChat extends Actor { | |
def receive = { | |
case (name:String, msg:String) => { | |
println("Server: " +name+": "+msg) | |
context.actorSelection("../client*") ! (name,msg) | |
} | |
} | |
} | |
class AkkaClient extends Actor { | |
def receive = { | |
case (from:String,msg:String) => {println(self.path.name + ": "+from+": "+msg)} | |
case msg:String => { | |
context.actorSelection("../server") ! (self.path.name, msg) | |
} | |
} | |
} | |
object AkkaChat extends App { | |
val system = ActorSystem("AkkaChat") | |
val actor = system.actorOf(Props[AkkaChat], "server") | |
val cJano = system.actorOf(Props[AkkaClient], "clientJano") | |
val cFero = system.actorOf(Props[AkkaClient], "clientFero") | |
cFero ! "ahoj svete" | |
cJano ! "nazdar" | |
} } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment