Пример #1
0
        public async Task Invoke(HttpContext context, GuardGoodsDbContext dbContext)
        {
            _dbContext       = dbContext;
            _goodsProcessing = new GoodsProcessing(dbContext);

            if (context.WebSockets.IsWebSocketRequest)
            {
                #region 解析参数
                if (!context.Request.Query.ContainsKey("action"))
                {
                    context.Response.StatusCode = 400;
                }
                GoodsPutRequest @params = null;
                if (context.Request.Query.TryGetValue("params", out StringValues value))
                {
                    @params = JsonConvert.DeserializeObject <GoodsPutRequest>(HttpUtility.UrlDecode(value.ToString()));
                }
                #endregion

                WebSocket webSocket = await context.WebSockets.AcceptWebSocketAsync();

                _stopwatch = new Stopwatch();
                _stopwatch.Start();
                _latestElapsed = 0;
                await Put(context, webSocket, @params);

                _stopwatch.Stop();
            }
            else
            {
                context.Response.StatusCode = 400;
                return;
            }
        }
Пример #2
0
 public GoodsProcessing(GuardGoodsDbContext dbContext)
 {
     _dbContext = dbContext;
 }