dummy_tv.py 文件源码

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

项目:home-assistant-dlna-dmr 作者: StevenLooman 项目源码 文件源码
def async_handle_subscribe(request, subscribed_clients, state_variables):
    callback_url = request.headers.get('CALLBACK')[1:-1]
    sid = 'uuid:' + str(uuid.uuid4())
    subscribed_clients[sid] = callback_url

    headers = {
        'SID': sid
    }

    @asyncio.coroutine
    def async_push_later(state_variable):
        yield from asyncio.sleep(0.5)
        yield from state_variable.async_notify_listeners()

    for state_variable in state_variables.values():
        LOGGER.debug('Pushing state_variable on SUBSCRIBE: %s', state_variable.name)
        asyncio.get_event_loop().create_task(async_push_later(state_variable))

    return web.Response(status=200, headers=headers)
#endregion


#region Unsubscribe
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号