示例#1
0
        private void InternalOnMessage(object sender, EndpointContext context)
        {
            if (this.Log.IsDebugEnabled())
            {
                this.Log.Debug("messsage from {0}: {1}", context.MessageFrom, this.Dump(context.Message));
            }
            if (this.OnMessage == null)
            {
                return;
            }

            ThreadPool.QueueUserWorkItem(o =>
            {
                if (!this.running)
                {
                    if (this.Log.IsDebugEnabled())
                    {
                        this.Log.Debug(string.Format("message dropped as client closed: {0}", this.Dump(context.Message)));
                    }
                    return;
                }

                Message msg = this.ParseMessage(context.Message);
                var args    = new MessageArgs(msg, m => this.Confirm(m));
                var sw      = new Stopwatch();
                try
                {
                    sw.Start();
                    this.OnMessage(this, args);
                    sw.Stop();
                }
                catch (Exception e)
                {
                    args.Fail(e.Message);
                }

                if (args._isFail)
                {
                    if (this.Log.IsDebugEnabled())
                    {
                        this.Log.Debug("process message error: {0}", args._reason);
                    }
                    return;
                }

                // prevent confirm attach
                if (sw.ElapsedMilliseconds <= 1)
                {
                    if (this.Log.IsDebugEnabled())
                    {
                        this.Log.Debug("maybe too fast or attack? server maybe reject your request");
                    }
                    Thread.Sleep(10);
                }

                if (args._isConfirmed)
                {
                    return;
                }
                try
                {
                    this.Confirm(msg);
                    if (this.Log.IsDebugEnabled())
                    {
                        this.Log.Debug("confirm message: {0}", this.Dump(context.Message));
                    }
                }
                catch (Exception e)
                {
                    this.Log.Warn(string.Format("confirm message {0} error {1}", this.Dump(context.Message), e.StackTrace));
                }
            });
        }
示例#2
0
 public GetKeyDataResponse(SubsystemRequest request, EndpointContext ctx)
     : base(request, ctx)
 {
 }
示例#3
0
 public TPMSubsystemResponseBase(SubsystemRequest request, EndpointContext ctx)
     : base(request, ctx)
 {
 }
示例#4
0
 public BaseServerSubsystem(EndpointContext context, IConnectionsConfiguration config)
     : base(context)
 {
     _config = config;
 }
示例#5
0
 public GetKeyDataRequest(EndpointContext ctx)
     : base(ctx)
 {
 }
示例#6
0
//		private AuthHandle _authHandle = null;
//
//		/// <summary>
//		/// Gets the authorization handle used for the hmac generation process
//		/// (only nonce values are used)
//		/// </summary>
//		public AuthHandle AuthHandle
//		{
//			get{ return _authHandle;}
//			set{ _authHandle = value;}
//		}
//
//		private byte[] _digest = null;
//
//		/// <summary>
//		/// The digest generated from the command to execute
//		/// </summary>
//		public byte[] Digest
//		{
//			get{ return _digest; }
//			set{ _digest = value; }
//		}
//
//		private bool _continueAuthSession = true;
//
//		public bool ContinueAuthSession
//		{
//			get{ return _continueAuthSession;}
//			set{ _continueAuthSession = value;}
//		}

        public GenerateHMACRequest(EndpointContext ctx)
            : base(ctx)
        {
        }
示例#7
0
 public GenerateHMACResponse(SubsystemRequest request, EndpointContext ctx)
     : base(request, ctx)
 {
 }
示例#8
0
        private void InternalOnMessage(object sender, EndpointContext context)
        {
            if (enableTraceLog)
            {
                this.Log.Info("messsage from {0}: {1}", context.MessageFrom, this.Dump(context.Message));
            }

            if (this.OnMessage == null)
            {
                return;
            }

            ThreadPool.QueueUserWorkItem(o =>
            {
                if (!this.running)
                {
                    this.Log.Info(string.Format("message dropped as client closed: {0}", this.Dump(context.Message)));
                    return;
                }

                Message msg = this.ParseMessage(context.Message);
                var args    = new MessageArgs(msg, m => this.Confirm(m.Id));
                var sw      = new Stopwatch();
                try
                {
                    sw.Start();
                    this.OnMessage(this, args);
                    sw.Stop();
                }
                catch (Exception e)
                {
                    args.Fail(e.Message);
                }

                if (args._isFail)
                {
                    this.Log.Info("process message error: {0}", args._reason);
                    this.Fail(msg.Id, args._reason.Length > 128 ? args._reason.Substring(0, 128) : args._reason);
                    return;
                }

                // prevent confirm attach
                if (sw.ElapsedMilliseconds <= 1)
                {
                    Thread.Sleep(10);
                }

                if (args._isConfirmed)
                {
                    return;
                }

                try
                {
                    this.Confirm(msg.Id);

                    if (enableTraceLog)
                    {
                        this.Log.Info("confirm message topic: {0}, dataid: {1}", msg.Topic, msg.Dataid);
                    }
                }
                catch (Exception e)
                {
                    this.Log.Warn(string.Format("confirm message {0} error {1}", this.Dump(context.Message), e.StackTrace));
                }
            });
        }
示例#9
0
 public SubsystemResponse(SubsystemRequest request, EndpointContext ctx)
     : base(ctx)
 {
     _request = request;
 }
示例#10
0
 public ConnectionInitializedCommand(ConnectionId id, EndpointContext endpoint) : base(id)
 {
     Endpoint = endpoint;
 }
 public TypedClientSubsystemRequest(EndpointContext ctx)
     : base(ctx)
 {
 }
 public ResponsePrintOnServerConsole(SubsystemRequest request, EndpointContext ctx)
     : base(request, ctx)
 {
 }
 public RequestPrintOnServerConsoleWithResponse(EndpointContext ctx)
     : base(ctx)
 {
 }
 public RequestPrintOnServerConsoleWithResponse(string text, EndpointContext ctx)
     : base(ctx)
 {
     _text = text;
 }