api.py 文件源码

python
阅读 34 收藏 0 点赞 0 评论 0

项目:dino 作者: thenetcircle 项目源码 文件源码
def on_disconnect() -> (int, None):
    """
    when a client disconnects or the server no longer gets a ping response from the client

    :return json if ok, {'status_code': 200}
    """
    user_id = str(environ.env.session.get(SessionKeys.user_id.value))
    data = {
        'verb': 'disconnect',
        'actor': {
            'id': user_id
        }
    }
    if not environ.env.config.get(ConfigKeys.TESTING):
        if environ.env.connected_user_ids.get(user_id) == request.sid:
            del environ.env.connected_user_ids[user_id]

    activity = as_parser(data)
    environ.env.observer.emit('on_disconnect', (data, activity))
    return ECodes.OK, None
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号