aboutsummaryrefslogtreecommitdiffstats
path: root/templates
diff options
context:
space:
mode:
authorGravatar Christopher Baklid <[email protected]>2018-05-24 21:45:25 +0200
committerGravatar Christopher Baklid <[email protected]>2018-05-24 21:45:25 +0200
commit10a205e97d399d1736fd9c806e1e309bb31ff28d (patch)
tree14ed25194db1f274e76a07fe0073db0e7d464a27 /templates
parentupdate readme (diff)
generate new queue based on session id to lock user to their own event chain
Diffstat (limited to 'templates')
-rw-r--r--templates/index.html19
1 files changed, 18 insertions, 1 deletions
diff --git a/templates/index.html b/templates/index.html
index d0b0630..ef53d74 100644
--- a/templates/index.html
+++ b/templates/index.html
@@ -3,9 +3,19 @@
<title>snekboxweb</title>
<script language="javascript" type="text/javascript">
+
let _ready = false
+let snekbox_id
var output;
+snekbox_id = sessionStorage.getItem("snekbox_id");
+console.log(snekbox_id)
+if (snekbox_id == null) {
+ snekbox_id = generate_id()
+ sessionStorage.setItem("snekbox_id", snekbox_id)
+ console.log(snekbox_id)
+}
+
function init(){
output = document.getElementById("output");
websocketHandler();
@@ -13,7 +23,7 @@ function init(){
function websocketHandler(){
var here = window.location.host;
- var wsUri = `ws://${here}/ws`;
+ var wsUri = `ws://${here}/ws/`+snekbox_id;
websocket = new WebSocket(wsUri);
websocket.onopen = function(evt) { onOpen(evt) };
websocket.onclose = function(evt) { onClose(evt) };
@@ -77,6 +87,13 @@ function sendFromInput(){
sendMessage(msg)
}
+function generate_id(){
+ return Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
+}
+
+
+
+
window.addEventListener("load", init, false);
</script>