コード例 #1
0
        public void Process(ISocketSession session, ReceivedEventArgs e)
        {
            var package = e.ToStr();
            var client  = session;

            var id = Guid.NewGuid().ToString();

            //缓存客户端会话
            RemoteSessionHelper.RemoteSessionCache.AddOrUpdate(id,
                                                               key => client,
                                                               (key, oldValue) =>
            {
                if (!oldValue.Disposed)
                {
                    oldValue.Dispose();
                }
                return(client);
            });

            //将数据包封装后放到redis中
            var dataPackage = new DataPacket {
                Id = id, Data = package, Date = DateTime.Now
            };                                                                                 //对当前接受数据进行封装

            _redisClient.Sadd(RedisKeyString.PackageList, dataPackage, RedisSerializeType.DataType);
            //数据包处理结束
        }