예제 #1
0
        public RpcSession(RpcSessionContext sessionContext)
        {
            if (sessionContext.Serializer == null)
            {
                throw new ArgumentNullException(nameof(sessionContext.Serializer));
            }
            if (sessionContext.Connection == null)
            {
                throw new ArgumentNullException(nameof(sessionContext.Connection));
            }
            if (sessionContext.LogManager == null)
            {
                throw new ArgumentNullException(nameof(sessionContext.LogManager));
            }
            if (sessionContext.TaskScheduler == null)
            {
                throw new ArgumentNullException(nameof(sessionContext.TaskScheduler));
            }

            this.requests                    = new ConcurrentDictionary <uint, RemotingRequest>();
            this.rpcSerializer               = sessionContext.Serializer;
            this.orderedExecution            = sessionContext.OrderedExecution;
            this.orderedExecutionTask        = Task.CompletedTask;
            this.orderedExecutionMaxQueue    = sessionContext.OrderedExecutionMaxQueue;
            this.remotingObjectConfiguration = sessionContext.RemotingObjectConfiguration;
            this.taskScheduler               = sessionContext.TaskScheduler;
            this.Connection                  = sessionContext.Connection;
            this.defaultExecutionTimeout     = sessionContext.DefaultExecutionTimeout;
            this.logger = sessionContext.LogManager.GetLogger(nameof(RpcSession));
            this.logger.Meta["kind"]                = this.GetType().Name;
            this.logger.Meta["connection_id"]       = this.Connection.Id;
            this.logger.Meta["connection_endpoint"] = new RefLogLabel <IRpcConnection>(this.Connection, s => s.RemoteEndpoint);
            this.logger.Meta["closed"]              = new RefLogLabel <RpcSession>(this, s => s.closed);
            this.logger.Meta["tag"]     = new RefLogLabel <RpcSession>(this, s => s.Tag);
            this.logger.Meta["latency"] = new RefLogLabel <RpcSession>(this, s =>
            {
                var lat = s.Connection.Latency;
                if (lat.HasValue)
                {
                    return(lat.Value);
                }
                else
                {
                    return("");
                }
            });
            this.logger.Debug($"{sessionContext.Connection} created {this}");
        }
예제 #2
0
 public ReadFormatterInfo(IReader reader, RpcSerializer serializer)
 {
     this.Serializer = serializer;
     this.Reader     = reader;
 }
예제 #3
0
 public WriteFormatterInfo(IWriter writer, RpcSerializer serializer)
 {
     this.Serializer = serializer;
     this.Writer     = writer;
 }