2019-02-02 23:53:49 +01:00
|
|
|
from typing import Dict, Optional
|
2016-11-27 06:14:48 +01:00
|
|
|
|
2016-11-30 21:45:02 +01:00
|
|
|
if False:
|
2018-03-15 01:21:27 +01:00
|
|
|
from zerver.tornado.event_queue import ClientDescriptor
|
2016-11-27 06:14:48 +01:00
|
|
|
|
2018-03-15 01:21:27 +01:00
|
|
|
descriptors_by_handler_id = {} # type: Dict[int, ClientDescriptor]
|
2016-11-27 06:14:48 +01:00
|
|
|
|
2018-10-27 03:07:32 +02:00
|
|
|
def get_descriptor_by_handler_id(handler_id: int) -> Optional['ClientDescriptor']:
|
2016-11-27 06:14:48 +01:00
|
|
|
return descriptors_by_handler_id.get(handler_id)
|
|
|
|
|
2018-03-15 01:21:27 +01:00
|
|
|
def set_descriptor_by_handler_id(handler_id: int,
|
|
|
|
client_descriptor: 'ClientDescriptor') -> None:
|
2016-11-27 06:14:48 +01:00
|
|
|
descriptors_by_handler_id[handler_id] = client_descriptor
|
|
|
|
|
2018-03-15 01:21:27 +01:00
|
|
|
def clear_descriptor_by_handler_id(handler_id: int,
|
|
|
|
client_descriptor: 'ClientDescriptor') -> None:
|
2016-11-27 06:14:48 +01:00
|
|
|
del descriptors_by_handler_id[handler_id]
|