Now, it is time to code on the UI on both the HTML layout and the WebSocket code in JavaScript. We will need to create a new file, located at ReactiveWebStore/app/views
.
Your chat_index.scala.html
file should look something like this:
@()(implicit flash:Flash) @main("Chat"){ <!DOCTYPE html> <meta charset="utf-8" /> <title>Chat Room</title> <script type="text/javascript"> var output; var websocket = new WebSocket("ws://localhost:9000/chat/ws"); function init(){ output = document.getElementById("output"); websocket.onmessage = function(evt) { writeToScreen('<span style="color:blue;">' + evt.data+ '</span>'); }; websocket.onerror = function(evt) { writeToScreen('<span style="color: red;">ERROR...