forked from RandmC13/gameboy-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.py
More file actions
53 lines (38 loc) · 1.21 KB
/
Copy pathclient.py
File metadata and controls
53 lines (38 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import asyncio
import websockets
import json
import numpy as np
from io import BytesIO
from matplotlib.pyplot import imshow,show
import zlib
async def hello():
uri = "ws://localhost:8765"
async with websockets.connect(uri) as websocket:
password = input("PWD >> ")
packet = {
"authentication": password,
"command": "authenticate"
}
await websocket.send(json.dumps(packet))
key = await websocket.recv()
print(key)
packet["authentication"] = key
packet["command"] = "start"
await websocket.send(json.dumps(packet))
res = await websocket.recv()
#load_bytes = BytesIO(res)
#image = np.load(load_bytes, allow_pickle=True)
#imshow(image)
#show()
image = json.loads(zlib.decompress(res))
print(image)
imshow(image)
show()
packet["command"] = "deauthenticate"
await websocket.send(json.dumps(packet))
res = await websocket.recv()
print(res)
#packet["authentication"] = "";
packet["command"] = "close";
await websocket.send(json.dumps(packet))
asyncio.get_event_loop().run_until_complete(hello())