def socket_register(username): session = data.sids_to_session[flask.request.sid] if username in data.users: user = data.users[username] data.sids_to_user[flask.request.sid] = user user.sid = flask.request.sid app.logger.info('Client {} rejoined as {}'.format( flask.request.sid, username)) else: user = data.User(sid=flask.request.sid, session=session, username=username) data.users[username] = user data.sids_to_user[flask.request.sid] = user app.logger.info('Client {} joied as {}'.format(flask.request.sid, username)) flask_socketio.emit('update', render_question(user, user.session, user.session.question_num), room=user.sid) flask_socketio.emit('update_left', render_sidebar(user, user.session), room=user.sid)
def socket_join(session_name): app.logger.debug('New client {} connected'.format(flask.request.sid)) _session = data.sessions[session_name] user = data.User(sid=flask.request.sid, session=_session) data.users[flask.request.sid] = user # Send initial colour picker flask_socketio.emit('update', flask.render_template('colour_picker.html', session=_session), room=flask.request.sid) flask_socketio.emit('update_left', render_sidebar(user, _session), room=flask.request.sid)
def render_question_full(_session, question_num): return flask.render_template(_session.questions[question_num].template, session=_session, user=data.User(), question_num=question_num)