I am following the Alex Hadik Flask Socketio tutorial, which talks about a simple bulb chat application
http://www.alexhadik.com/blog/2015/1/29/using-socketio-with-python-and-flask-on-heroku
I would like to pass the message to all connected users except the sender. I passed the flash drive using init .py, but I'm still not sure how to do this.
Here is the server code.
from flask import Flask, render_template,request
from flask.ext.socketio import SocketIO,emit,send
import json,sys
app = Flask(__name__)
socketio = SocketIO(app)
clients = {}
@app.route("/")
def index():
return render_template('index.html',)
@socketio.on('send_message')
def handle_source(json_data):
text = json_data['message'].encode('ascii', 'ignore')
current_client = request.namespace
current_client_id = request.namespace.socket.sessid
update_client_list(current_client,current_client_id)
if clients.keys():
for client in clients.keys():
if not current_client_id in client:
clients[client].socketio.emit('echo', {'echo': 'Server Says: '+text})
def update_client_list(current_client,current_client_id):
if not current_client_id in clients: clients[current_client_id] = current_client
return
if __name__ == "__main__":
socketio.run(app,debug = False)
. dict (), request.name, . [client].socketio.emit() , , - , .
- , , ?