当前位置: 首页>>代码示例>>Python>>正文


Python flask_socketio.disconnect方法代码示例

本文整理汇总了Python中flask_socketio.disconnect方法的典型用法代码示例。如果您正苦于以下问题:Python flask_socketio.disconnect方法的具体用法?Python flask_socketio.disconnect怎么用?Python flask_socketio.disconnect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在flask_socketio的用法示例。


在下文中一共展示了flask_socketio.disconnect方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create_app

# 需要导入模块: import flask_socketio [as 别名]
# 或者: from flask_socketio import disconnect [as 别名]
def create_app(redis_url):
    socketio = SocketIO(logger=True)

    app = Flask(__name__)
    app.config.from_object(config)

    @app.route("/")
    def index():
        return jsonify({"name": "%s Event stream" % config.APP_NAME})

    @socketio.on("connect", namespace="/events")
    def connected():
        try:
            verify_jwt_in_request()
            app.logger.info("New websocket client connected")
        except Exception:
            app.logger.info("New websocket client failed to connect")
            disconnect()
            return False

    @socketio.on("disconnect", namespace="/events")
    def disconnected():
        app.logger.info("Websocket client disconnected")

    @socketio.on_error("/events")
    def on_error(error):
        app.logger.error(error)

    socketio.init_app(app, message_queue=redis_url, async_mode="gevent")
    return (app, socketio) 
开发者ID:cgwire,项目名称:zou,代码行数:32,代码来源:event_stream.py

示例2: diagnostic

# 需要导入模块: import flask_socketio [as 别名]
# 或者: from flask_socketio import disconnect [as 别名]
def diagnostic():
    """
    Get services journal and status
    """
    getServicesStatus()
    logs = []
    for service in services_list:
        sysctl_status = subprocess.run(['systemctl', 'status', service['service_unit']],
                                stdout=subprocess.PIPE,
                                universal_newlines=True)
        journalctl = subprocess.run(['journalctl', '--since', '7 days ago', '-u', service['service_unit']], 
                                 stdout=subprocess.PIPE, 
                                 universal_newlines=True)
        
        #Replace carrier return to <br> for html view
        sysctl_status = sysctl_status.stdout.replace('\n', '<br>') 
        journalctl = journalctl.stdout.replace('\n', '<br>')
        active_state = "Active" if service['active'] == True else "Inactive"
        logs.append({'name' : service['service_unit'], 'active' : active_state, 'sysctl_status' : sysctl_status, 'journalctl' : journalctl})
        
    return render_template('diagnostic.html', logs = logs)
    

#### Handle connect/disconnect events #### 
开发者ID:Stefal,项目名称:rtkbase,代码行数:26,代码来源:server.py

示例3: disconnect_by_sid

# 需要导入模块: import flask_socketio [as 别名]
# 或者: from flask_socketio import disconnect [as 别名]
def disconnect_by_sid(sid: str) -> None:
        if sid is None:
            raise ValueError('need sid to disconnect client')
        environ.env._force_disconnect_by_sid(sid, '/ws') 
开发者ID:thenetcircle,项目名称:dino,代码行数:6,代码来源:sockets.py

示例4: on_login

# 需要导入模块: import flask_socketio [as 别名]
# 或者: from flask_socketio import disconnect [as 别名]
def on_login(data: dict, activity: Activity) -> (int, str):
    try:
        status_code, msg = api.on_login(data, activity)
        if status_code != 200:
            disconnect()
        return status_code, msg
    except Exception as e:
        logger.error('could not login, will disconnect client: %s' % str(e))
        logger.exception(traceback.format_exc())
        environ.env.capture_exception(sys.exc_info())
        return 500, str(e) 
开发者ID:thenetcircle,项目名称:dino,代码行数:13,代码来源:sockets.py

示例5: on_leave

# 需要导入模块: import flask_socketio [as 别名]
# 或者: from flask_socketio import disconnect [as 别名]
def on_leave(data: dict, activity: Activity) -> (int, Union[str, dict, None]):
    return api.on_leave(data, activity)


# no pre-processing for disconnect event 
开发者ID:thenetcircle,项目名称:dino,代码行数:7,代码来源:sockets.py

示例6: handle_client_disconnect

# 需要导入模块: import flask_socketio [as 别名]
# 或者: from flask_socketio import disconnect [as 别名]
def handle_client_disconnect(msg):
    disconnect()


# Affectiva Client ready to receive photos (base64_images) 
开发者ID:Notabela,项目名称:Lie_to_me,代码行数:7,代码来源:websockets.py

示例7: handle_next_frame_request

# 需要导入模块: import flask_socketio [as 别名]
# 或者: from flask_socketio import disconnect [as 别名]
def handle_next_frame_request(json):
    global current_frame
    
    # print("Previous frame data: {0}".format(str(json)))

    if json['data']:
        # anger, contempt, disgust, engagement, fear, joy, sadness, surprise, valence
        emotions = json['data'][0]['emotions']
        expressions = json['data'][0]['expressions']
        eye_closure = expressions['eyeClosure']

        emotion_data.append(emotions)
        eye_closure_data.append(eye_closure)
    else:
        # No data was obtained
        emotion_data.append(None)
        eye_closure_data.append(None)

    if current_frame[0] < len(base64_frames):
        emit('next_frame', [current_frame[0], base64_frames[current_frame[0]]])
        current_frame[0] += 1
    else:
        emit('no_more_frames', 'Completed')
        # disconnect()

        # Parse Data and Save Data to Disk
        blink_data = detect_blinks(eye_closure_data, video_fps_rate[0])
        microexpression_data = microexpression_analyzer(emotion_data, video_fps_rate[0])
        json_path = os.path.join(basedir, 'static', 'data', 'tmp_json')

        with shelve.open(os.path.join(json_path, 'facial_data.shlf')) as shelf:
            shelf['emotion_data'] = emotion_data
            shelf['micro_expression_data'] = microexpression_data
            shelf['blink_data'] = blink_data

        # Notify client that facial data write is complete
        emit('data_complete', 'Facial_Complete') 
开发者ID:Notabela,项目名称:Lie_to_me,代码行数:39,代码来源:websockets.py

示例8: terminate_interview_connection

# 需要导入模块: import flask_socketio [as 别名]
# 或者: from flask_socketio import disconnect [as 别名]
def terminate_interview_connection():
    sys.stderr.write("terminate_interview_connection\n")
    # hopefully the disconnect will be triggered
    # if request.sid in threads:
    #     rr.publish(request.sid, json.dumps(dict(origin='client', message='KILL', sid=request.sid)))
    socketio.emit('terminate', {}, namespace='/wsinterview', room=request.sid)
    #disconnect() 
开发者ID:jhpyle,项目名称:docassemble,代码行数:9,代码来源:socketserver.py

示例9: on_interview_manual_disconnect

# 需要导入模块: import flask_socketio [as 别名]
# 或者: from flask_socketio import disconnect [as 别名]
def on_interview_manual_disconnect(data):
    sys.stderr.write("Client manual disconnect\n")
    yaml_filename = data['i']
    session_info = get_session(yaml_filename)
    session_id = session_info['uid']
    the_user_id = session.get('user_id', 't' + str(session.get('tempuser', None)))
    if request.sid in secrets:
        del secrets[request.sid]
    if session_id is not None:
        rr.delete('da:interviewsession:uid:' + str(session_id) + ':i:' + str(yaml_filename) + ':userid:' + str(the_user_id))
        key = 'da:session:uid:' + str(session_id) + ':i:' + str(yaml_filename) + ':userid:' + str(the_user_id)
        rr.expire(key, 10)
        rr.publish(request.sid, json.dumps(dict(origin='client', message='KILL', sid=request.sid))) 
开发者ID:jhpyle,项目名称:docassemble,代码行数:15,代码来源:socketserver.py

示例10: terminate_monitor_connection

# 需要导入模块: import flask_socketio [as 别名]
# 或者: from flask_socketio import disconnect [as 别名]
def terminate_monitor_connection():
    sys.stderr.write("terminate_monitor_connection\n")
    # hopefully the disconnect will be triggered
    # if request.sid in threads:
    #     rr.publish(request.sid, json.dumps(dict(origin='client', message='KILL', sid=request.sid)))
    socketio.emit('terminate', {}, namespace='/monitor', room=request.sid)
    #disconnect() 
开发者ID:jhpyle,项目名称:docassemble,代码行数:9,代码来源:socketserver.py

示例11: terminate_observer_connection

# 需要导入模块: import flask_socketio [as 别名]
# 或者: from flask_socketio import disconnect [as 别名]
def terminate_observer_connection():
    sys.stderr.write("terminate_observer_connection\n")
    # hopefully the disconnect will be triggered
    # if request.sid in threads:
    #     rr.publish(request.sid, json.dumps(dict(origin='client', message='KILL', sid=request.sid)))
    socketio.emit('terminate', {}, namespace='/observer', room=request.sid)
    #disconnect() 
开发者ID:jhpyle,项目名称:docassemble,代码行数:9,代码来源:socketserver.py

示例12: default_socketio_error_handler

# 需要导入模块: import flask_socketio [as 别名]
# 或者: from flask_socketio import disconnect [as 别名]
def default_socketio_error_handler(e):
    disconnect() 
开发者ID:TitanEmbeds,项目名称:Titan,代码行数:4,代码来源:utils.py


注:本文中的flask_socketio.disconnect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。