| 51 | |
| 52 | |
| 53 | class Channel(AsyncIOEventEmitter): |
| 54 | def __init__(self, connection: "Connection", object: "ChannelOwner") -> None: |
| 55 | super().__init__() |
| 56 | self._connection = connection |
| 57 | self._guid = object._guid |
| 58 | self._object = object |
| 59 | self.on("error", lambda exc: self._connection._on_event_listener_error(exc)) |
| 60 | |
| 61 | async def send( |
| 62 | self, |
| 63 | method: str, |
| 64 | timeout_calculator: TimeoutCalculator, |
| 65 | params: Dict = None, |
| 66 | is_internal: bool = False, |
| 67 | title: str = None, |
| 68 | ) -> Any: |
| 69 | return await self._connection.wrap_api_call( |
| 70 | lambda: self._inner_send(method, timeout_calculator, params, False), |
| 71 | is_internal, |
| 72 | title, |
| 73 | ) |
| 74 | |
| 75 | async def send_return_as_dict( |
| 76 | self, |
| 77 | method: str, |
| 78 | timeout_calculator: TimeoutCalculator, |
| 79 | params: Dict = None, |
| 80 | is_internal: bool = False, |
| 81 | title: str = None, |
| 82 | ) -> Any: |
| 83 | return await self._connection.wrap_api_call( |
| 84 | lambda: self._inner_send(method, timeout_calculator, params, True), |
| 85 | is_internal, |
| 86 | title, |
| 87 | ) |
| 88 | |
| 89 | def send_no_reply( |
| 90 | self, |
| 91 | method: str, |
| 92 | timeout_calculator: TimeoutCalculator, |
| 93 | params: Dict = None, |
| 94 | is_internal: bool = False, |
| 95 | title: str = None, |
| 96 | ) -> None: |
| 97 | # No reply messages are used to e.g. __waitInfo__(after). |
| 98 | self._connection.wrap_api_call_sync( |
| 99 | lambda: self._connection._send_message_to_server( |
| 100 | self._object, |
| 101 | method, |
| 102 | _augment_params(params, timeout_calculator), |
| 103 | True, |
| 104 | ), |
| 105 | is_internal, |
| 106 | title, |
| 107 | ) |
| 108 | |
| 109 | async def _inner_send( |
| 110 | self, |