From 1a0b4bd23ac1b49ddb2f2bbbaf0dde1f9156be18 Mon Sep 17 00:00:00 2001 From: Jakob Odersky Date: Sun, 13 Nov 2016 17:51:34 -0800 Subject: Implement basic frontend --- server/app/controllers/HomeController.scala | 4 ++++ server/app/controllers/actors.scala | 2 +- server/app/views/chat.scala.html | 11 +++++++++++ server/app/views/index.scala.html | 8 +------- server/conf/routes | 1 + 5 files changed, 18 insertions(+), 8 deletions(-) create mode 100644 server/app/views/chat.scala.html (limited to 'server') diff --git a/server/app/controllers/HomeController.scala b/server/app/controllers/HomeController.scala index 4d48c98..7f5e596 100644 --- a/server/app/controllers/HomeController.scala +++ b/server/app/controllers/HomeController.scala @@ -31,6 +31,10 @@ class HomeController @Inject() ( Ok(views.html.index()) } + def chat(uid: String) = Action { implicit request => + Ok(views.html.chat(uid)) + } + def socket(uid: String) = WebSocket.accept[Command, Event] { request => ActorFlow.actorRef(out => Props(classOf[ClientActor], uid, room, out)) } diff --git a/server/app/controllers/actors.scala b/server/app/controllers/actors.scala index f10f925..138a13f 100644 --- a/server/app/controllers/actors.scala +++ b/server/app/controllers/actors.scala @@ -41,10 +41,10 @@ class RoomActor extends Actor { } case Terminated(client) => - clients -= client for ( (cl, _) <- clients ) { cl ! Left(clients(client)) } + clients -= client case Broadcast(content) => val origin = clients(sender) diff --git a/server/app/views/chat.scala.html b/server/app/views/chat.scala.html new file mode 100644 index 0000000..3a1fa30 --- /dev/null +++ b/server/app/views/chat.scala.html @@ -0,0 +1,11 @@ +@(uid: String) + +@main("Welcome to Chat") { +
+ Loading +
+ + +} diff --git a/server/app/views/index.scala.html b/server/app/views/index.scala.html index 4b71c59..05dbc0d 100644 --- a/server/app/views/index.scala.html +++ b/server/app/views/index.scala.html @@ -1,11 +1,5 @@ @() @main("Welcome to Chat") { -
- hello -
- - + } diff --git a/server/conf/routes b/server/conf/routes index ab400c7..5d2c73e 100644 --- a/server/conf/routes +++ b/server/conf/routes @@ -5,6 +5,7 @@ # An example controller showing a sample home page GET / controllers.HomeController.index +GET /chat/:uid controllers.HomeController.chat(uid) GET /socket/:uid controllers.HomeController.socket(uid) # Map static resources from the /public folder to the /assets URL path -- cgit v1.2.3