I'm running the SocketIO server with something like:
from socketio.server import SocketIOServer
server = SocketIOServer(
('127.0.0.1', '8000'),
resource='socket.io',
)
server.serve_forever()
I then have a namespace:
class Foo(BaseNamespace, BroadcastMixin):
def on_msg(self, data):
self.emit(data['msg'])
And finally, I have a route such as:
module = Blueprint('web', __name__)
@module.route('/')
def index():
pkt = dict(
type='event',
name='new_visitor',
endpoint='/foo'
)
## HERE: How do I get the "socket" to look through each connection
#for sessid, socket in blah.socket.server.sockets.iteritems():
# socket.send_packet(pkt)
return render_template('index.html')
So, the above commented part is where I have issue.
What I've done so far:
- I dove in to the gevent-socketio code and see that the sockets are kept tracked there. But I am not sure what would be the next step.
- Noticed that, in Flask,
request.environ
has asocketio
value that corresponds to the object. However, that's only on SocketIO requests.
Any clues or hints would be very appreciated.