Permalink
Browse files

edit test messages, or send arbitary messages in test room.

  • Loading branch information...
ilanpillemer committed Aug 3, 2017
1 parent e1ba03d commit e532f45faa6528d79a3f1d7e2b3ad9ff270de04b
Showing with 49 additions and 23 deletions.
  1. +30 −12 app/views/index.scala.html
  2. +19 −11 public/javascripts/main.js
View
@@ -2,25 +2,43 @@
@main("sample scala room") {
<div class="jumbotron">
<h1>Welcome to your sample scala room running on play!</h1>
<h1>Sample scala room is running!</h1>
<p>This is a template for a starter scala/play based room in game-on. Use it as a starting point to create something more unique by building on or modifying it.</p>
</div>
<div class="page-header">
<h4>Preformed Messages, try them, edit them, or just write your own</h2>
</div>
<p>
<button type="button" onclick="roomHello()" class="btn btn-default">Hello</button>
<button type="button" onclick="roomHello()" class="btn btn-primary">Hello</button>
<button type="button" onclick="argh()" class="btn btn-primary">Do Undefined</button>
<button type="button" onclick="roomGoodbye()" class="btn btn-success">Goodbye</button>
<button type="button" onclick="chat()" class="btn btn-info">Chat</button>
<button type="button" onclick="play()" class="btn btn-warning">Play</button>
<button type="button" onclick="gowest()" class="btn btn-danger">Go west</button>
<button type="button" onclick="roomGoodbye()" class="btn btn-primary">Goodbye</button>
<button type="button" onclick="chat()" class="btn btn-primary">Chat</button>
<button type="button" onclick="play()" class="btn btn-primary">Play</button>
<button type="button" onclick="gowest()" class="btn btn-primary">Go west</button>
</p>
<p>
<button type="button" onclick="clearScreen()" class="btn btn-default">Clear Output</button>
</p>
<div class="panel panel-info">
<div class="panel-heading">
<h3 class="panel-title">Web Socket Latest Response</h3>
<div class="row">
<div class="col-sm-3 well">
<p><button type="button" onclick="send()" class="btn btn-info">Send to Room!</button></p>
<div class="panel panel-info">
<div class="panel-heading">
<h3 class="panel-title">Test message for the Room</h3>
</div>
<div> <textarea id="input" class="form-control" id="text" name="text" placeholder="Type in your message" rows="5"></textarea></div>
</div>
</div>
<div class="col-sm-3 well">
<p><button type="button" onclick="clearScreen()" class="btn btn-success">Clear Output</button></p>
<div class="panel panel-info">
<div class="panel-heading">
<h3 class="panel-title">Room's Response</h3>
</div>
<div id="output"></div>
</div>
</div>
<div id="output" class="panel-body"></div>
</div>
}
View
@@ -3,6 +3,7 @@ var output;
function init() {
output = document.getElementById("output");
input = document.getElementById("input");
testWebSocket();
}
@@ -12,16 +13,16 @@ function roomHello() {
"userId": "sally876",
"version": 2
};
doSend("roomHello,_," + JSON.stringify(roomHello));
writeToInput("roomHello,_," + JSON.stringify(roomHello));
}
function roomGoodbye() {
var roomGoodbye = {
"username": "Harry",
"userId": "harry912"
};
var roomGoodbye = {
"username": "Harry",
"userId": "harry912"
};
doSend("roomGoodbye,_," + JSON.stringify(roomGoodbye));
writeToInput("roomGoodbye,_," + JSON.stringify(roomGoodbye));
}
function chat() {
@@ -30,7 +31,7 @@ function chat() {
"userId": "scarlet973",
"content": "Fancy running into you in a room like this..."
};
doSend("room,_," + JSON.stringify(chat));
writeToInput("room,_," + JSON.stringify(chat));
}
function play() {
@@ -39,7 +40,7 @@ function play() {
"userId": "highlander54",
"content": "/play with the other one."
};
doSend("room,_," + JSON.stringify(play));
writeToInput("room,_," + JSON.stringify(play));
}
function argh() {
@@ -48,7 +49,7 @@ function argh() {
"userId": "mick42",
"content": "/asdsdfsadfa"
};
doSend("room,_," + JSON.stringify(asdfs));
writeToInput("room,_," + JSON.stringify(asdfs));
}
function gowest() {
@@ -57,7 +58,7 @@ function gowest() {
"userId": "scarlet973",
"content": "/go west"
};
doSend("room,_," + JSON.stringify(west));
writeToInput("room,_," + JSON.stringify(west));
}
@@ -69,10 +70,18 @@ function testWebSocket() {
websocket.onerror = function(evt) { onError(evt) };
}
function send() {
doSend(input.value)
}
function clearScreen() {
output.innerHTML=""
}
function writeToInput(message) {
input.value=message;
}
function writeToScreen(message) {
var pre = document.createElement("p");
pre.style.wordWrap = "break-word";
@@ -82,7 +91,6 @@ function writeToScreen(message) {
function onOpen(evt) {
writeToScreen("CONNECTED");
roomHello()
}
function onClose(evt) {

0 comments on commit e532f45

Please sign in to comment.