This commit is contained in:
Yamozha 2021-02-04 00:04:26 +02:00
parent 91e0557b20
commit 98f8b51a42
3 changed files with 11 additions and 5 deletions

View File

@ -26,7 +26,9 @@ async def serveStuff(websocket, path):
# bad way to send balance to given user - FIX!!! # bad way to send balance to given user - FIX!!!
elif requestText == "STATUSONUSER": elif requestText == "STATUSONUSER":
name, balance = checkBalance("1") name, balance = checkBalance("1")
await websocket.send(balance) print(name)
await websocket.send(f"Your balance is: {balance}")
await websocket.send(f"Welcome, {name}!")
else: else:
await websocket.send("We don't accept DoS") await websocket.send("We don't accept DoS")

View File

@ -10,7 +10,9 @@
<body> <body>
<h1 id="odometer" class="odometer">This is where you'll see the thing</h1> <h1 id="odometer" class="odometer">This is where you'll see the thing</h1>
<script type="text/javascript" src="scripts/getCurrentCoins.js"></script> <script type="text/javascript" src="scripts/getCurrentCoins.js"></script>
<br>
<h2 id="balance">Your balance is:</h2> <h2 id="balance">Your balance is:</h2>
<h2 id="username"></h2>
</body> </body>
</html> </html>

View File

@ -1,6 +1,6 @@
socketAdress="ws://localhost:8765" socketAdress="ws://localhost:8765"
// Lacking protocol for ids lmao // Lacking protocol for ids lmao
document.cookie = "id=1"; document.cookie = "id=2";
function currencyTicker(){ function currencyTicker(){
var ws = new WebSocket(socketAdress); var ws = new WebSocket(socketAdress);
@ -26,10 +26,12 @@ function userBalance(){
ws.onmessage = function(evt){ ws.onmessage = function(evt){
var balanceStatus = evt.data; var balanceStatus = evt.data;
// this doesnt work, fix pls // this doesnt work, fix pls
var websiteReplace = "Your balance is:${balanceStatus}" w = document.getElementById("balance").innerHTML = balanceStatus;
w = document.getElementById("balance").innerHTML = websiteReplace ws.onmessage = function(evt){
w = document.getElementById("username").innerHTML = evt.data;
}
} }
} }
var t=setInterval(currencyTicker,5000); var t=setInterval(currencyTicker,5000);
var y=setInterval(userBalance,10000); var y=setInterval(userBalance,5000);