mirror of https://github.com/Askill/r_place.git
adedd reconnect to client
This commit is contained in:
parent
9668282ec3
commit
750678ed82
|
|
@ -0,0 +1,16 @@
|
||||||
|
#FFFFFF
|
||||||
|
#E4E4E4
|
||||||
|
#888888
|
||||||
|
#222222
|
||||||
|
#FFA7D1
|
||||||
|
#E50000
|
||||||
|
#E59500
|
||||||
|
#A06A42
|
||||||
|
#E5D900
|
||||||
|
#94E044
|
||||||
|
#02BE01
|
||||||
|
#00D3DD
|
||||||
|
#0083C7
|
||||||
|
#0000EA
|
||||||
|
#CF6EE4
|
||||||
|
#820080
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
<template>
|
||||||
|
<canvas id="main_canvas" height="1000" width="1000"> </canvas>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<!-- Add "scoped" attribute to limit CSS to this component only -->
|
||||||
|
<style scoped>
|
||||||
|
h3 {
|
||||||
|
margin: 40px 0 0;
|
||||||
|
}
|
||||||
|
ul {
|
||||||
|
list-style-type: none;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
li {
|
||||||
|
display: inline-block;
|
||||||
|
margin: 0 10px;
|
||||||
|
}
|
||||||
|
a {
|
||||||
|
color: #42b983;
|
||||||
|
}
|
||||||
|
canvas { border: 1px solid black; }
|
||||||
|
</style>
|
||||||
|
|
@ -59,23 +59,25 @@ def closest_match(rgb, color_map):
|
||||||
return min(range(len(rgb_colors)), key=lambda i: eucleadian_distance(rgb, color_map[i]))
|
return min(range(len(rgb_colors)), key=lambda i: eucleadian_distance(rgb, color_map[i]))
|
||||||
|
|
||||||
async def sender(img):
|
async def sender(img):
|
||||||
async with websockets.connect("ws://localhost:8080/set", timeout=60) as websocket:
|
while True:
|
||||||
|
try:
|
||||||
while True:
|
async with websockets.connect("ws://localhost:8080/set", timeout=60) as websocket:
|
||||||
rx = random.randint(0, 999)
|
while True:
|
||||||
ry = random.randint(0, 999)
|
rx = random.randint(0, 999)
|
||||||
message = pixel(
|
ry = random.randint(0, 999)
|
||||||
x=rx,
|
message = pixel(
|
||||||
y=ry,
|
x=rx,
|
||||||
color= closest_match(img[rx][ry], rgb_colors),
|
y=ry,
|
||||||
timestamp=int(time.time()),
|
color= closest_match(img[rx][ry], rgb_colors),
|
||||||
userid=1,
|
timestamp=int(time.time()),
|
||||||
)
|
userid=1,
|
||||||
await websocket.send(json.dumps(message.__dict__))
|
)
|
||||||
succ = await websocket.recv()
|
await websocket.send(json.dumps(message.__dict__))
|
||||||
if succ != "0":
|
succ = await websocket.recv()
|
||||||
print(message, "was not set")
|
if succ != "0":
|
||||||
|
print(message, "was not set")
|
||||||
|
except:
|
||||||
|
print("reconnecting")
|
||||||
|
|
||||||
|
|
||||||
async def client():
|
async def client():
|
||||||
|
|
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 45 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 81 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 120 KiB |
Loading…
Reference in New Issue