-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStructureModels.py
More file actions
124 lines (115 loc) · 4.01 KB
/
StructureModels.py
File metadata and controls
124 lines (115 loc) · 4.01 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
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
121
122
123
124
import json
import uuid
from hashlib import sha256
import time
import sys
import struct
from binary import *
class Message:
def Deserialize(_bytes: bytes):
stream = BinaryStream(_bytes)
this = {}
this["type"] = stream.ReadString()
this["content"] = stream.ReadByteArray()
this["metadata"] = stream.ReadString()
return this
def Serialize(this):
stream = BinaryStream()
stream.WriteString(this["type"])
stream.WriteByteArray(this["content"])
stream.WriteString(this.get("metadata", ""))
return stream.base_stream
class BridgeActionModel:
def Deserialize(_bytes: bytes):
stream = BinaryStream(_bytes)
this = {}
this["action"] = stream.ReadInt32()
this["content"] = stream.ReadByteArray()
this["username"] = stream.ReadString()
this["metadata"] = stream.ReadString()
this["playSound"] = stream.ReadBool()
return this
def Serialize(this):
stream = BinaryStream()
stream.WriteInt32(this["action"])
stream.WriteByteArray(this["content"])
stream.WriteString(this["username"])
stream.WriteString(this["metadata"])
stream.WriteBool(this["playSound"])
return stream.base_stream
class ServerConfigModel:
def Deserialize(_bytes: bytes):
stream = BinaryStream(_bytes)
this = {}
this["action"] = stream.ReadInt32()
this["userCap"] = stream.ReadInt32()
this["acceptingConnections"] = stream.ReadBool()
this["newPassword"] = stream.ReadString()
this["lobbyMode"] = stream.ReadInt32()
return this
def Serialize(this):
raise NotImplementedError()
class KickUserModel:
def Deserialize(_bytes: bytes):
stream = BinaryStream(_bytes)
this = {}
this["username"] = stream.ReadString()
this["reason"] = stream.ReadString()
return this
def Serialize(this):
raise NotImplementedError()
class LayoutModel:
def Deserialize(_bytes: bytes):
stream = BinaryStream(_bytes)
this = {}
this["targetAllUsers"] = stream.ReadBool()
this["layoutData"] = stream.ReadByteArray()
return this
def Serialize(this):
raise NotImplementedError()
class ServerInfoModel:
def Deserialize(_bytes: bytes):
raise NotImplementedError() # this is never actually needed as the server is the only one sending this data
def Serialize(this):
stream = BinaryStream()
stream.WriteInt32(this["usersConnected"])
stream.WriteInt32(this["userCap"])
stream.WriteBool(this["acceptingConnections"])
stream.WriteInt32(this["lobbyMode"])
stream.WriteBool(this["isFrozen"])
stream.WriteStrings(this["playerNames"])
return stream.base_stream
class MousePositionModel:
def Deserialize(_bytes: bytes):
stream = BinaryStream(_bytes)
this = {}
this["username"] = stream.ReadString()
this["position"] = stream.ReadVector3()
this["pointerMode"] = stream.ReadInt32()
this["pointerColor"] = stream.ReadColor()
return this
def Serialize(this):
stream = BinaryStream()
stream.WriteString(this["username"])
stream.WriteVector3(this["position"])
stream.WriteInt32(this["pointerMode"])
stream.WriteColor(this["pointerColor"])
return stream.base_stream
def stringResponse(string:str):
stream = BinaryStream()
stream.WriteString(string)
return stream.base_stream
class ChatMessageModel:
def Deserialize(_bytes: bytes):
stream = BinaryStream(_bytes)
this = {}
this["message"] = stream.ReadString()
this["username"] = stream.ReadString()
this["nameColor"] = stream.ReadColor()
return this
def Serialize(this):
stream = BinaryStream()
stream.WriteString(this["message"])
stream.WriteString(this["username"])
stream.WriteColor(this["nameColor"])
return stream.base_stream