Admin controller draft
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
package actors
|
||||
|
||||
import akka.actor.{Actor, ActorLogging, Props}
|
||||
import akka.actor.{Actor, ActorLogging, ActorRef, ActorSystem, Props}
|
||||
import akka.event.LoggingReceive
|
||||
import akka.pattern.ask
|
||||
import akka.util.Timeout
|
||||
@@ -20,8 +20,8 @@ class LobbiesActor extends Actor with LazyLogging {
|
||||
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}")
|
||||
val lobbyActor = context.actorOf(Props(new LobbieActor(LobbyUser(hostName, hostActorRef))),
|
||||
s"lobbyActor-${(math.random * 100000000L).toLong}")
|
||||
lobbyActor.tell(WatchLobby("watchIt"), hostActorRef)
|
||||
case JoinLobbyByActorName(lobbyName, userName) =>
|
||||
// get or create the StockActor for the symbol and forward this message
|
||||
@@ -44,7 +44,7 @@ class LobbiesActor extends Actor with LazyLogging {
|
||||
case None => logger.error(s"Can't watch lobby $lobbyName - lobby not exists")
|
||||
}
|
||||
case UnWatchAllLobbies =>
|
||||
context.children.foreach( _.tell(LeaveLobby, sender))
|
||||
context.children.foreach(_.tell(LeaveLobby, sender))
|
||||
case GetAllLobbies =>
|
||||
sender ! context.children.toList.map(lobbyActor =>
|
||||
Await.result(lobbyActor ? InfoQuery, 1.second))
|
||||
@@ -59,4 +59,9 @@ case class JoinLobbyByActorName(actorName: String, userName: String)
|
||||
|
||||
case class ObserveLobbyByActorName(actorName: String)
|
||||
|
||||
case object UnWatchAllLobbies
|
||||
case object UnWatchAllLobbies
|
||||
|
||||
object LobbiesActor {
|
||||
implicit val actorSystem: ActorSystem = ActorSystem()
|
||||
val actor: ActorRef = actorSystem.actorOf(Props[LobbiesActor]())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user