Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(13)  |  Call(11)  |  Derive(0)  |  Import(2)

src/f/l/Flask-SocketIO-HEAD/example/app.py   Flask-SocketIO(Download)
from threading import Thread
from flask import Flask, render_template, session, request
from flask.ext.socketio import SocketIO, emit, join_room, leave_room
 
app = Flask(__name__)
def test_message(message):
    session['receive_count'] = session.get('receive_count', 0) + 1
    emit('my response',
         {'data': message['data'], 'count': session['receive_count']})
 
 
@socketio.on('my broadcast event', namespace='/test')
def test_message(message):
    session['receive_count'] = session.get('receive_count', 0) + 1
    emit('my response',
def join(message):
    join_room(message['room'])
    session['receive_count'] = session.get('receive_count', 0) + 1
    emit('my response',
         {'data': 'In rooms: ' + ', '.join(request.namespace.rooms),
def leave(message):
    leave_room(message['room'])
    session['receive_count'] = session.get('receive_count', 0) + 1
    emit('my response',
         {'data': 'In rooms: ' + ', '.join(request.namespace.rooms),

src/f/l/Flask-SocketIO-HEAD/test_socketio.py   Flask-SocketIO(Download)
 
from flask import Flask, session
from flask.ext.socketio import SocketIO, send, emit, join_room, leave_room
 
app = Flask(__name__)
def on_custom_event(data):
    emit('my custom response', data)
 
@socketio.on('my custom namespace event', namespace='/test')
def on_custom_event_test(data):
    emit('my custom namespace response', data, namespace='/test')
 
@socketio.on('my custom broadcast event')
def on_custom_event_broadcast(data):
    emit('my custom response', data, broadcast=True)
def on_custom_event_broadcast_test(data):
    emit('my custom namespace response', data, namespace='/test',
         broadcast=True)
 
@socketio.on('join room')