Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public async Task Run()
- {
- if (runned)
- throw new InvalidOperationException($"{nameof(TTTClient)} is already runned.");
- runned = true;
- while (true)
- {
- var msg = await ReciveAsync();
- //Сюда можешь не смотреть
- if (msg is Response response)
- {
- if (requests.TryGetRequestTask(response.RequestID, out var task))
- {
- task.TrySetResult(response);
- }
- }
- //вызов зарегистрированных обработчиков
- else
- {
- var type = msg.GetType();
- var handlers = messageHandlers.GetListeners(type);
- foreach (var item in handlers)
- {
- item(msg);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment