-
Notifications
You must be signed in to change notification settings - Fork 0
/
client_test.py
120 lines (113 loc) · 2.89 KB
/
client_test.py
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
from websocket import create_connection
import json
from copy import *
import uuid
import time
from StructureModels import *
class ActionType:
CREATE_EDGE = 0
CREATE_JOINT = 1
DELETE_EDGE = 2
DELETE_JOINT = 3
TRANSLATE_JOINT = 4
message_template = {
"type":"BridgeAction",
"content":{
"action":ActionType.CREATE_JOINT,
"content":""
}
}
MODE = "listen" + "no"
ws = create_connection("ws://127.0.0.1:11000/a?username=test_user")
print("ws", ws.recv())
while True:
ws.send(
MousePositionModel.Serialize(
{
"username":"a",
"position":[5,5,0],
"pointerMode":1,
"pointerColor":[255,0,0]
}
)
)
print("sent mouse pos")
#ws2 = create_connection("ws://127.0.0.1:8181/test?username=user2&password=aaa")
#print("ws", ws.recv())
#print("ws2", ws2.recv())
#ws.send(json.dumps({
# "type": "ServerConfig",
# "content":json.dumps({
# "newPassword":"bbb",
# "lobbyMode":2
# })
#}))
#ws.send(json.dumps({
# "type": "ServerConfig",
# "content":json.dumps({
# "userCap":20
# })
#}))
#ws.send(json.dumps({
# "type": "ServerInfo",
# "content":""
#}))
#print("ws", ws.recv())
#ws.send(json.dumps({
# "type": "KickUser",
# "content":json.dumps({"username":"user2", "reason":"yes"})
#}))
#print("ws", ws.recv())
#print("ws2", ws2.recv())
#ws.send(json.dumps({
# "type": "CreateInvite",
# "content":json.dumps({
# "uses":1
# })
#}))
#invite = json.loads(ws.recv())["content"]
#print(invite)
#ws3 = create_connection(f"ws://127.0.0.1:8181/test?username=user3&invite={invite}")
#print("ws", ws.recv())
#ws4 = create_connection(f"ws://127.0.0.1:8181/test?username=user4&invite={invite}")
#print("ws4", ws4.recv())
#ws5 = create_connection(f"ws://127.0.0.1:8181/test?username=user5")
#ws.send(json.dumps({
# "type": "CreateInvite",
# "content":json.dumps({
# "uses":1
# })
#}))
#invite = json.loads(ws.recv())["content"]
#print(invite)
#def createJoint(x:float,y:float,z:float, m_IsAnchor=False, m_IsSplit=False):
# guid = str(uuid.uuid4())
# joint = {
# "m_Pos": {
# "x": x,
# "y": y,
# "z": z
# },
# "m_IsAnchor": m_IsAnchor,
# "m_IsSplit": m_IsSplit,
# "m_Guid": guid
# }
# return joint
#def createEdge(m_NodeA_Guid, m_NodeB_Guid, m_Material=1):
# edge = {
# "m_Material": m_Material,
# "m_NodeA_Guid": m_NodeA_Guid,
# "m_NodeAPart": 1,
# "m_NodeB_Guid": m_NodeB_Guid,
# "m_NodeBPart": 0,
# }
# return edge
#
#
#def send_action(content, action):
# message = deepcopy(message_template)
# message["content"]["action"] = action
# message["content"]["content"] = json.dumps(content)
# message["content"] = json.dumps(message["content"])
# ws.send(json.dumps(message))
# print(f"sent action {action}")