def joined(_message): join_room(room) active_session = get_active_session() if not active_session: app.logger.warn("Message ignored: No active session") return messages = [rest_chat_msg(ent) for ent in load_chat_log(active_session.id)] emit('messages', messages, room=request.sid)
def move_to(destination_id: int) -> None: active_session = get_active_session() start_id = active_session.current_location_id active_session.previous_location_id = start_id active_session.current_location_id = destination_id db.session.add(active_session) db.session.commit() handle_navigation(start_id, destination_id, active_session.id)
def text(message): if not current_user.is_authenticated: return disconnect() message_text = message['message'] active_session = get_active_session() if not active_session: app.logger.warn("Message ignored: No active session") return ent = save_log_entry(active_session, current_user, message_text) handle_message(ent)
def chatlog_entry(): data = request.get_json() if 'message' not in data: return '', 400 message = data['message'] active_session = get_active_session() if not active_session: app.logger.error("No active session") return '', 500 ent = save_log_entry(active_session, current_user, message) handle_message(ent) return '', 204
def guide_controls(): active_session = get_active_session() if not active_session: app.logger.error("No active session") return '', 500 adjacent_locations = get_adjacent_locations( active_session.current_location_id) path = get_path(active_session.previous_location_id, active_session.current_location_id) return render_template('guide_controls.html', active_session=active_session, adjacent_locations=adjacent_locations, description=path.description)
def render_scout_view(): return render_template('scout_view.html', active_session=get_active_session())
def render_guide_view(): return render_template('guide_view.html', active_session=get_active_session())
def get_current_location() -> Location: active_session = get_active_session() return get_location(active_session.current_location_id)