-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathReceiver.py
34 lines (33 loc) · 1.12 KB
/
Receiver.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
class Receiver:
"""
Know how to perform the operations associated with carrying out a
request. Any class may serve as a Receiver.
"""
def __init__(self, session_key):
# most of the commands are encrypted (use a session key to encrypt data)
# override those in command definition
self.encrypt = True
self.compress = True
self.session_key = session_key
def action(self, data, msgid):
response = {
'compress': self.compress,
'data': {
'crypto_type': 'COMMON',
'flowid': None,
'msgid': msgid,
'result': 'NOERR',
'rqid': 0,
'xuid': 0,
},
'original_size': 0,
'session_crypto': self.encrypt,
'session_key': None
}
for key in data:
response['data'][key] = data[key]
# if self.encrypt:
# response['session_key'] = get_session_key??
# add default headers to the response body
# check for authorization?
return response