Initial commit
This commit is contained in:
commit
1dad72215e
3 changed files with 1283 additions and 0 deletions
8
beats.sublime-project
Normal file
8
beats.sublime-project
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"folders":
|
||||
[
|
||||
{
|
||||
"path": "/Users/joshua/Documents/www/vadovas/beats"
|
||||
}
|
||||
]
|
||||
}
|
1229
beats.sublime-workspace
Normal file
1229
beats.sublime-workspace
Normal file
File diff suppressed because it is too large
Load diff
46
websocket.html
Normal file
46
websocket.html
Normal file
|
@ -0,0 +1,46 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8" />
|
||||
<title>WebSocket Test</title>
|
||||
<script language="javascript" type="text/javascript">
|
||||
var wsUri = "ws://vadovas-studios.com:7681";
|
||||
var output;
|
||||
var n;
|
||||
|
||||
function init() {
|
||||
output = document.getElementById("output");
|
||||
n = 10;
|
||||
testWebSocket();
|
||||
}
|
||||
function testWebSocket() {
|
||||
websocket = new WebSocket(wsUri);
|
||||
websocket.onopen = function (evt) {onOpen(evt)};
|
||||
websocket.onclose = function (evt) {onClose(evt)};
|
||||
websocket.onmessage = function (evt) {onMessage(evt)};
|
||||
websocket.onerror = function (evt) {onError(evt)};
|
||||
}
|
||||
function onOpen(evt) {
|
||||
writeToScreen("CONNECTED");
|
||||
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) {
|
||||
writeToScreen("DISCONNECTED");
|
||||
}
|
||||
function onMessage(evt) {
|
||||
writeToScreen(evt.data);
|
||||
setTimeout(function(){doSend(evt.data);}, 1000);
|
||||
}
|
||||
function onError(evt) {
|
||||
writeToScreen('<span style="color: red;">ERROR:</span> ' + evt.data);
|
||||
}
|
||||
function doSend(message) {
|
||||
websocket.send(message);
|
||||
}
|
||||
function writeToScreen(message) {
|
||||
output.innerHTML = message;
|
||||
}
|
||||
window.addEventListener("load", init, false);
|
||||
</script>
|
||||
|
||||
<div style="font-family:Georgia, serif; text-align: center; font-size: 48pt;"id="output"></div>
|
||||
|
||||
</html>
|
Reference in a new issue