Exemple #1
0
 /// <summary>
 /// 生成键
 /// </summary>
 public override void SetId()
 {
     if (_snowFlakeGenerator == null)
     {
         _snowFlakeGenerator = SnowFlakeGenerator.Instance();
     }
     Id = _snowFlakeGenerator.GetKey();
 }
Exemple #2
0
        /// <summary>
        /// 创建行处理TCP客户端(若logger参数为空则用ILoggerFactory初始化内部日志)
        /// </summary>
        /// <param name="logger"></param>
        /// <param name="iP">IP</param>
        /// <param name="port">端口</param>
        public LineTcpClient(ILogger <LineTcpClient <T> > logger, IPAddress iP, int port)
        {
            if (iP == null)
            {
                throw new ArgumentNullException(nameof(iP));
            }
            _endpoint = new IPEndPoint(iP, port);

            _socket = new Socket(SocketType.Stream, ProtocolType.Tcp);

            _bcol = new BlockingCollection <T>();

            _keyGenerator = SnowFlakeGenerator.Instance();

            if (logger == null)
            {
                _logger = LoggerHelper.Create <LineTcpClient <T> >();
                return;
            }
            _logger = logger;
        }