dist-iot-net/src/py-cli/websock/bob.py

24 lines
659 B
Python
Executable File

"""
!/usr/bin/env python
https://pypi.org/project/websockets/
@author Lachezar Todorov
"""
import asyncio
import encrypt_decrypt
from websockets import serve
class Bob():
async def decrypt(websocket, path, privateKey):
async for message in websocket:
message = await websocket.recv()
decryptedMessage = encrypt_decrypt.encrypt_decrypt.decryption(message, privateKey)
await websocket.send(decryptedMessage)
async def main(privateKey):
async with serve(Bob.decrypt, "localhost", 8765, privateKey):
await asyncio.Future() # run forever
#asyncio.run(main())