Decider v 0.9
This commit is contained in:
@@ -16,23 +16,26 @@ class LobbiesActor extends Actor with LazyLogging {
|
||||
|
||||
val lobbies: ListBuffer[String] = ListBuffer()
|
||||
|
||||
def receive = LoggingReceive {
|
||||
case CreateLobby(userName) =>
|
||||
val lobbyActor = context.actorOf(Props(new LobbieActor(userName, sender)),
|
||||
def receive: Receive = LoggingReceive {
|
||||
case CreateLobby(hostName) =>
|
||||
val hostActorRef = sender
|
||||
logger.info(s"Player ${hostActorRef.path.name} create lobby.")
|
||||
val lobbyActor = context.actorOf(Props(new LobbieActor(LobbyUser(hostName,hostActorRef))),
|
||||
s"lobbyActor-${(math.random*100000000L).toLong}")
|
||||
lobbyActor.tell(WatchLobby("watchIt"), sender)
|
||||
lobbyActor.tell(WatchLobby("watchIt"), hostActorRef)
|
||||
case JoinLobbyByActorName(lobbyName, userName) =>
|
||||
// get or create the StockActor for the symbol and forward this message
|
||||
val user = sender
|
||||
context.child(lobbyName) match {
|
||||
case Some(lobbyActor) => lobbyActor ! JoinLobbyAsPlayer(LobbyUser(userName, user))
|
||||
case None => logger.error(s"Can't watch lobby $lobbyName - lobby not exists")
|
||||
}
|
||||
case watchLobby@WatchLobby(lobbyName) =>
|
||||
// get or create the StockActor for the symbol and forward this message
|
||||
context.child(lobbyName) match {
|
||||
case Some(lobbyActor) => lobbyActor forward watchLobby
|
||||
case None => logger.error(s"Can't watch lobby $lobbyName - lobby not exists")
|
||||
}
|
||||
case unwatchLobby@LeaveLobby(symbol) =>
|
||||
// if there is a StockActor for the symbol forward this message
|
||||
context.child(symbol).foreach(_.forward(unwatchLobby))
|
||||
case banMap@BanMap(map) =>
|
||||
logger.info(s"forvard ban $map")
|
||||
context.children.foreach(_.forward(banMap))
|
||||
case UnWatchAllLobbies =>
|
||||
context.children.foreach( _.tell(LeaveLobby, sender))
|
||||
case GetAllLobbies =>
|
||||
@@ -45,4 +48,6 @@ class LobbiesActor extends Actor with LazyLogging {
|
||||
|
||||
case object GetAllLobbies
|
||||
|
||||
case class JoinLobbyByActorName(actorName: String, userName: String)
|
||||
|
||||
case object UnWatchAllLobbies
|
||||
Reference in New Issue
Block a user