-
Notifications
You must be signed in to change notification settings - Fork 1
/
CorpsMsg.py
88 lines (59 loc) · 2.13 KB
/
CorpsMsg.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
''' CorpsMsg Message Formats '''
from enum import IntEnum
from ResultsCache import ResultsCacheKey
class CorpsMsgType(IntEnum):
ConcRet = 0
ConcRequ = 1
class CorpsMsgPriority(IntEnum):
MetaRet = 0 # Highest priority
MetaRequ = 1 # ...to
BaseRet = 2 # ...the
BaseRequ = 3 # ...lowest
# MsgFlags
NoReplyBitMask = 0x0001
CORPSMSG_HDR_SIZE = 8
MAX_BODY_LENGTH = pow(2,64)-1
class CorpsRequest():
def __init__(self):
self.MsgType = CorpsMsgType.ConcRequ
self.MsgPriority = CorpsMsgPriority.BaseRequ
self.MsgFlags = 0
self.MsgId = ResultsCacheKey(0,0,0)
self.ClientAddr = 0
self.ServerAddr = 0
self.MethodName = 0
self.Args = 0
self.KwArgs = 0
self.MsgHdlr = 0 # used on server to pass between threads
def __repr__(self):
output = []
output.append(f'\tMsgType: {self.MsgType.name}\n')
output.append(f'\tMsgPriority: {self.MsgPriority.name}\n')
output.append(f'\tMsgId: {self.MsgId}\n')
output.append(f'\tClientAddr: {self.ClientAddr}\n')
output.append(f'\tServerAddr: {self.ServerAddr}\n')
output.append(f'\tMethodName: {self.MethodName}\n')
output.append(f'\tArgs: {self.Args}\n')
output.append(f'\tKwArgs: {self.KwArgs}\n')
return ' '.join(output)
class CorpsRetType(IntEnum):
Ok = 0
AsyncExecutionExc = 1
AsyncAttributeExc = 2
class CorpsReturn():
def __init__(self):
self.MsgType = CorpsMsgType.ConcRet
self.MsgPriority = CorpsMsgPriority.BaseRet
self.ClientAddr = 0
self.ServerAddr = 0
self.Ret = 0
self.RetType = CorpsRetType.Ok
def __repr__(self):
output = []
output.append(f'\tMsgType: {self.MsgType.name}\n')
output.append(f'\tMsgPriority: {self.MsgPriority.name}\n')
output.append(f'\tClientAddr: {self.ClientAddr}\n')
output.append(f'\tServerAddr: {self.ServerAddr}\n')
output.append(f'\tRet: {self.Ret}\n')
output.append(f'\tRetType: {self.RetType.name}\n')
return ' '.join(output)