コード例 #1
0
        public override void ChannelActive(IChannelHandlerContext context)
        {
            var g = group;

            if (g.IsNull())
            {
                ExtensionSettings.Preference.RunLocker(() =>
                {
                    if (group.IsNull())
                    {
                        g = group = new DefaultChannelGroup(context.Executor);
                    }
                });
            }

            var message = $"Welcome to {Dns.GetHostName()} secure chat server!\n";

            context.WriteAndFlushAsync(message);
            g.Add(context.Channel);
            _logger.LogInformation(message);
        }