12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- package controllers
- import play.api._
- import play.api.mvc._
- import play.api.libs.json._
- import play.api.libs.iteratee._
- import models._
- import akka.actor._
- import scala.concurrent.duration._
- object Application extends Controller {
-
- /**
- * Just display the home page.
- */
- def index = Action { implicit request =>
- Ok(views.html.index())
- }
-
- /**
- * Display the chat room page.
- */
- def chatRoom(username: Option[String]) = Action { implicit request =>
- username.filterNot(_.isEmpty).map { username =>
- Ok(views.html.chatRoom(username))
- }.getOrElse {
- Redirect(routes.Application.index).flashing(
- "error" -> "Please choose a valid username."
- )
- }
- }
- def chatRoomJs(username: String) = Action { implicit request =>
- Ok(views.js.chatRoom(username))
- }
-
- /**
- * Handles the chat websocket.
- */
- def chat(username: String) = WebSocket.async[JsValue] { request =>
- ChatRoom.join(username)
-
- }
-
- }
|