Example #1
0
        public Task SendClientMessageAsync <T>(Guid clientId, T message)
            where T : Message
        {
            if (!_clientCollection.TryGet(clientId, out var client))
            {
                _logger.Debug("Unknown client {ClientId}", clientId);
                return(Task.CompletedTask);
            }

            var protocolType = message
                               .GetType()
                               .GetTypeInfo()
                               .GetCustomAttribute(typeof(PriorityMessage)) != null
                ? ProtocolType.Tcp
                : ProtocolType.Udp;

            return(_messageCenter.SendMessage(client.Uris[protocolType], message));
        }