Esempio n. 1
0
        public override void ChannelActive(IChannelHandlerContext context)
        {
            var host = context.GetRemoteHost();

            if (_channelCache.TryAdd(host, context.Channel))
            {
                _logger.LogInformation("客户端{}已经连接到本机服务", host);
            }
            else
            {
                throw new Exception($"客户端{host}建立连接失败");
            }
            base.ChannelActive(context);
        }