Convert Enum to IntValue.
This commit is contained in:
parent
ae937aa48b
commit
1d2cdfb01e
1 changed files with 2 additions and 0 deletions
|
@ -70,6 +70,8 @@ class MessageServer:
|
||||||
async def _write_message(self, writer, message):
|
async def _write_message(self, writer, message):
|
||||||
assert isinstance(writer, asyncio.StreamWriter)
|
assert isinstance(writer, asyncio.StreamWriter)
|
||||||
logger.debug('Writing {}'.format(self.__message_log(message)))
|
logger.debug('Writing {}'.format(self.__message_log(message)))
|
||||||
|
# use value of enum since Enum is not JSON serializable
|
||||||
|
message['type'] = message['type'].value
|
||||||
# json string (str) -> encode to utf8 (bytes) -> compress (bytes) -> add length header (bytes)
|
# json string (str) -> encode to utf8 (bytes) -> compress (bytes) -> add length header (bytes)
|
||||||
raw_msg = json.dumps(message).encode('utf-8')
|
raw_msg = json.dumps(message).encode('utf-8')
|
||||||
compressed = self._compressor.compress(raw_msg)
|
compressed = self._compressor.compress(raw_msg)
|
||||||
|
|
Loading…
Reference in a new issue