diff --git a/examples/request_ws2p.py b/examples/request_ws2p.py index 7d4375d8888d223facb31e11e1d16f98034cf2bd..da108805378a009e9e43258ae83048f84cab6c7c 100644 --- a/examples/request_ws2p.py +++ b/examples/request_ws2p.py @@ -61,20 +61,20 @@ async def main(): async with ws_connection as ws: print("Connected successfully to web socket endpoint") - print("Send message CONNECT : " + connect_message) + print("Send CONNECT message") await ws.send_str(connect_message) # Iterate on each message received... async for msg in ws: # if message type is text... if msg.type == aiohttp.WSMsgType.TEXT: - print(msg.data) + # print(msg.data) try: - # Validate jsonschema and return a the json dict + # Validate json string with jsonschema and return a dict data = parse_text(msg.data, ws2p.network.WS2P_CONNECT_MESSAGE_SCHEMA) print("Received a CONNECT message") remote_connect_document = Connect(CURRENCY, data["pub"], data["challenge"], data["sig"]) - print("Remote CONNECT message signature is valid") + print("Received CONNECT message signature is valid") ack_message = Ack(CURRENCY, signing_key.pubkey, remote_connect_document.challenge).get_signed_json( @@ -85,13 +85,13 @@ async def main(): except jsonschema.exceptions.ValidationError: try: - # Validate jsonschema and return a the json dict + # Validate json string with jsonschema and return a dict data = parse_text(msg.data, ws2p.network.WS2P_ACK_MESSAGE_SCHEMA) print("Received a ACK message") # create ACK document from ACK response to verify signature Ack(CURRENCY, data["pub"], connect_document.challenge, data["sig"]) - print("Remote ACK message signature is valid") + print("Received ACK message signature is valid") # Si ACK response ok, create OK message ok_message = Ok(CURRENCY, signing_key.pubkey, connect_document.challenge).get_signed_json( signing_key) @@ -101,12 +101,12 @@ async def main(): await ws.send_str(ok_message) except jsonschema.exceptions.ValidationError: try: - # Validate jsonschema and return a the json dict + # Validate json string with jsonschema and return a dict data = parse_text(msg.data, ws2p.network.WS2P_OK_MESSAGE_SCHEMA) print("Received a OK message") Ok(CURRENCY, remote_connect_document.pubkey, connect_document.challenge, data["sig"]) - print("Remote OK message signature is valid") + print("Received OK message signature is valid") except jsonschema.exceptions.ValidationError: pass