aboutsummaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
authorJakob Odersky <jakob@odersky.com>2016-11-13 17:51:34 -0800
committerJakob Odersky <jakob@odersky.com>2016-11-13 17:51:34 -0800
commit1a0b4bd23ac1b49ddb2f2bbbaf0dde1f9156be18 (patch)
tree62d8bd2f8842e18ffc14dd22dbb08db901df12fc /server
parent7efed1380f6a6cfc8d0b95015f1fa167b4a7bc23 (diff)
downloadplay-scalajs-chat-1a0b4bd23ac1b49ddb2f2bbbaf0dde1f9156be18.tar.gz
play-scalajs-chat-1a0b4bd23ac1b49ddb2f2bbbaf0dde1f9156be18.tar.bz2
play-scalajs-chat-1a0b4bd23ac1b49ddb2f2bbbaf0dde1f9156be18.zip
Implement basic frontend
Diffstat (limited to 'server')
-rw-r--r--server/app/controllers/HomeController.scala4
-rw-r--r--server/app/controllers/actors.scala2
-rw-r--r--server/app/views/chat.scala.html11
-rw-r--r--server/app/views/index.scala.html8
-rw-r--r--server/conf/routes1
5 files changed, 18 insertions, 8 deletions
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") {
+ <main id="root">
+ Loading
+ </main>
+ <script src="@routes.Assets.versioned("client-fastopt.js")" type="text/javascript"></script>
+ <script type="text/javascript">
+ chat.Main().main("@uid")
+ </script>
+}
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") {
- <main id="root">
- hello
- </main>
- <script src="@routes.Assets.versioned("client-fastopt.js")" type="text/javascript"></script>
- <script type="text/javascript">
- chat.Main().main()
- </script>
+
}
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