I must be missing a fundamental piece of the socketio picture:
Here is a normal request:
def broadcast(request):
print request.server
return HttpResponse(status=200)
I'd like to broadcast out a message to everyone connected.
This code lives inside a namespace:
def broadcast_msg(self, msg):
"""
This is sent to all in the sockets in this particular Namespace,
including itself.
"""
pkt = dict(type="event",
name='msg',
args=str(msg),
endpoint=self.ns_name)
for sessid, socket in self.socket.server.sockets.iteritems():
socket.send_packet(pkt)
I thought I could just use
for sessid, socket in self.socket.server.sockets.iteritems():
socket.send_packet(pkt)
but I can't seem to find where socket is set. I tried looking inside request.environ['SOCKETIO'] but it is not there because the WSGIServer does not set it for non socket io requests.
Then I started digging into gevent and seeing if I could find all greenlets and maybe pull the socket pointer from them but that got me nowhere.
Where is the handle to the sockets?