Browse Source

page now shows other peoples

master
Joshua Moerman 11 years ago
parent
commit
6e1d09d916
  1. 2
      .gitignore
  2. 1229
      beats.sublime-workspace
  3. 20
      websocket.html

2
.gitignore

@ -0,0 +1,2 @@
*.sublime-workspace

1229
beats.sublime-workspace

File diff suppressed because it is too large

20
websocket.html

@ -2,13 +2,13 @@
<meta charset="utf-8" /> <meta charset="utf-8" />
<title>WebSocket Test</title> <title>WebSocket Test</title>
<script language="javascript" type="text/javascript"> <script language="javascript" type="text/javascript">
var wsUri = "ws://vadovas-studios.com:7681"; var wsUri = "ws://127.0.0.1:7681";
var output; var people;
var n; var myName = Math.random().toString(36).substring(7);
function init() { function init() {
output = document.getElementById("output"); people = document.getElementById("people");
n = 10; document.getElementById("myName").innerHTML = myName;
testWebSocket(); testWebSocket();
} }
function testWebSocket() { function testWebSocket() {
@ -19,15 +19,14 @@
websocket.onerror = function (evt) {onError(evt)}; websocket.onerror = function (evt) {onError(evt)};
} }
function onOpen(evt) { function onOpen(evt) {
writeToScreen("CONNECTED"); doSend(myName);
doSend("In JavaScript, I rewrite every function so that it can end as soon as possible. You want the browser back in control so it can make your DOM changes.");
} }
function onClose(evt) { function onClose(evt) {
writeToScreen("DISCONNECTED"); writeToScreen("DISCONNECTED");
} }
function onMessage(evt) { function onMessage(evt) {
writeToScreen(evt.data); writeToScreen(evt.data);
setTimeout(function(){doSend(evt.data);}, 1000); setTimeout(function(){doSend(myName);}, 1000);
} }
function onError(evt) { function onError(evt) {
writeToScreen('<span style="color: red;">ERROR:</span> ' + evt.data); writeToScreen('<span style="color: red;">ERROR:</span> ' + evt.data);
@ -36,11 +35,12 @@
websocket.send(message); websocket.send(message);
} }
function writeToScreen(message) { function writeToScreen(message) {
output.innerHTML = message; people.innerHTML = message;
} }
window.addEventListener("load", init, false); window.addEventListener("load", init, false);
</script> </script>
<div style="font-family:Georgia, serif; text-align: center; font-size: 48pt;"id="output"></div> <p>My name is: <span id="myName"></span>
<p>Response of server: <span id="people"></span>
</html> </html>