[06 Python OpenCV] Construct2 and Python Websocket

Published: 12 February 2021
on channel: Paul Chin
473
6

This video shows you how to create a client using Construct2 (a game engine) and a server using Python Websocket. We will be using these technologies later in our OpenCV projects. So it is good to introduce them here first.

Here is the code with some modification. I added a counter variable which will show an incrementing counter with each new message echoed back to client:

###### websock2.py ######
import asyncio
import websockets

import asyncio
import websockets

counter = 0
async def echo(websocket, path):
async for message in websocket:
global counter # to access global variables inside functions
counter = counter + 1
await websocket.send(f"Got your message: {message} {counter}")

start_server = websockets.serve(echo, "localhost", 8080)

asyncio.get_event_loop().run_until_complete(start_server)
asyncio.get_event_loop().run_forever()


On this page of the site you can watch the video online [06 Python OpenCV] Construct2 and Python Websocket with a duration of hours minute second in good quality, which was uploaded by the user Paul Chin 12 February 2021, share the link with friends and acquaintances, this video has already been watched 473 times on youtube and it was liked by 6 viewers. Enjoy your viewing!