package controllers

import actors._
import akka.NotUsed
import akka.actor._
import akka.event.Logging
import akka.pattern.ask
import akka.stream._
import akka.stream.scaladsl._
import akka.util.Timeout
import com.typesafe.config.ConfigFactory
import javax.inject._
import org.reactivestreams.Publisher
import play.api.libs.json._
import play.api.mvc._

import scala.concurrent.duration._
import scala.concurrent.{ExecutionContext, Future}

/**
 * This class creates the actions and the websocket needed.
 */
@Singleton
class AdminController @Inject()(cc: ControllerComponents) extends AbstractController(cc) {

  implicit val actorSystem: ActorSystem = ActorSystem()
  implicit val ec: ExecutionContext = defaultExecutionContext

  // Use a direct reference to SLF4J
  private val logger = org.slf4j.LoggerFactory.getLogger("controllers.HomeController")

  // Home page that renders template
  def viewAllLobbies() = Action { implicit request =>
    logger.info(s"Received request from: ${request.remoteAddress}")
    Ok(views.html.admin())
  }

  def banLobby(lobbyActorName: String): Unit = {

  }

  def reloadConfig()= Action { implicit request =>
    ConfigFactory.invalidateCaches()
    logger.info("Config reloaded")
    Ok("Config reloaded")
  }
}
