async def send_admin_message(self, msg: Message): if self.agent_admin_key and self.admin_key: msg = await crypto.pack_message(self.wallet_handle, Serializer.pack(msg), [self.admin_key], self.agent_admin_key) msg = msg.decode('ascii') else: msg = msg.as_json() await self.outbound_admin_message_queue.put(msg)
def pack(msg: Message) -> bytes: """ Serialize from Message to json string or from dictionary to json string. """ # TODO: Should return bytes and not string # return msg.as_json().encode() return msg.as_json()
def pack(msg: Message) -> str: """ Serialize from Message to json string or from dictionary to json string. """ return msg.as_json()
def serialize(msg: Message) -> bytes: """ Serialize from Message to json string or from dictionary to json string. """ return msg.as_json().encode('utf-8')