// This is the part of the actor that handles the chat rooms and pushes messages to clients case Join(roomname) => { if (rooms.contains(roomname)) { val newuuid = UUID.randomUUID() val ch: Enumerator[JsValue] = Concurrent.unicast[JsValue]( onStart = (c) => { Logger.info("Client add to room %s".format(roomname)) rooms(roomname) += (newuuid -> c) }, onComplete ={ () => self ! Quit(roomname, newuuid) }, onError = (str, in) => { Logger.info(str) self ! Quit(roomname,newuuid) } ).onDoneEnumerating(() => self ! Quit(roomname, newuuid) ) sender ! ch } else { sender ! Enumerator.eof[String] } } case Quit(roomname,ch) => { Logger.info("Chat client disconnect requested") if (rooms.contains(roomname)){ Logger.info("Chat client disconnect") rooms(roomname) -= ch } }