[06 Python OpenCV] Construct2 and Python Websocket

Publié le: 12 février 2021
sur la chaîne: 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()


Sur cette page du site, vous pouvez voir la vidéo en ligne [06 Python OpenCV] Construct2 and Python Websocket durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur Paul Chin 12 février 2021, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 473 fois et il a aimé 6 téléspectateurs. Bon visionnage!