
'''

test websocket server
'''

import asyncio
import websockets

print('starting WS.........')

async def handler(websocket):
    while True:
        message = await websocket.recv()
        print(message)
        if (message == "hello"):
            print('Hi')
            await websocket.send("hi there")
            websockets.broadcast(connected, message)


async def main():
    print('starting main WS.........')
    async with websockets.serve(handler, "localhost", 8765):
        await asyncio.Future()  # run forever


asyncio.run(main())
