I use django and dwebsocket. There is a warning in my browser console. Also it runs well. There is no problem :). But i wondered.
enter image description here enter image description here
views.py
import threading
from django.shortcuts import render_to_response
from dwebsocket.decorators import accept_websocket
def index(request):
return render_to_response('index.html', {})
clients = []
@accept_websocket
def echo(request):
if request.is_websocket:
lock = threading.RLock()
try:
lock.acquire()
clients.append(request.websocket)
for message in request.websocket:
if not message:
break
for client in clients:
client.send(message)
finally:
clients.remove(request.websocket)
lock.release()
Comments
Post a Comment