diff --git a/gestaoRaul/comandas/__pycache__/htmx_views.cpython-310.pyc b/gestaoRaul/comandas/__pycache__/htmx_views.cpython-310.pyc index 3bae9cc..363284e 100644 Binary files a/gestaoRaul/comandas/__pycache__/htmx_views.cpython-310.pyc and b/gestaoRaul/comandas/__pycache__/htmx_views.cpython-310.pyc differ diff --git a/gestaoRaul/comandas/htmx_views.py b/gestaoRaul/comandas/htmx_views.py index d07c216..2aea7a9 100644 --- a/gestaoRaul/comandas/htmx_views.py +++ b/gestaoRaul/comandas/htmx_views.py @@ -9,6 +9,20 @@ from payments.models import Payments from typePay.models import TypePay from gestaoRaul.decorators import group_required +import asyncio +import websockets + +async def enviar_mensagem(msg): + uri = "ws://localhost:8765" # Substitua pela URI do seu servidor WebSocket + async with websockets.connect(uri) as websocket: + await websocket.send(msg) + print(f"> Enviado: {msg}") + + resposta = await websocket.recv() + print(f"< Recebido: {resposta}") + + + def somar(consumo:ProductComanda, comanda:Comanda): parcial = Payments.objects.filter(comanda=comanda) @@ -50,6 +64,15 @@ def addProduct(request, product_id, comanda_id): if product.cuisine == True: order = Order(id_comanda=comanda, id_product=product, productComanda=product_comanda, obs='') order.save() + msg = JsonResponse({ + 'type': 'broadcast', + 'message': f'