public KestrelRequestHandler(Func <WsStream, Task> connectionAdded, int bufferSize, CancellationToken stopToken, string defaultPage = Config.Version) { // create a raw middleware _wsMiddleware = new WebSocketMiddleware(async ctx => { if (ctx.WebSockets.IsWebSocketRequest) { WebSocket webSocket = await ctx.WebSockets.AcceptWebSocketAsync(); var sId = Guid.NewGuid(); await webSocket.SendAsync(new ArraySegment <byte>(sId.ToByteArray()), WebSocketMessageType.Binary, true, CancellationToken.None); var wsc = new WsStream(new WStreamBaseSocket(webSocket, true), sId); // dont block the current task #pragma warning disable 4014 Task.Run(() => connectionAdded.Invoke(wsc)); #pragma warning restore 4014 while (webSocket.State == WebSocketState.Open && !stopToken.IsCancellationRequested) { await Task.Delay(100); } wsc.Close(); } else { await ctx.Response.WriteAsync(defaultPage); } }, Options.Create(new WebSocketOptions() { ReceiveBufferSize = bufferSize }), NullLoggerFactory.Instance); }
public async Task <IActionResult> Add() { try { int account = int.Parse(HttpContext.Request.Form["Account"]); var file = HttpContext.Request.Form.Files[0]; var fileId = "tws" + DateTimeOffset.UtcNow.ToUnixTimeSeconds(); var filePath = Path.GetTempFileName(); var fileName = ContentDispositionHeaderValue.Parse(file.ContentDisposition).FileName.Trim('"'); var fileExtension = Path.GetExtension(fileName); fileName = fileId + fileExtension; fileName = Path.Combine(this._hostingEnvironment.ContentRootPath, "Uploads/") + fileName; using (var stream = new FileStream(fileName, FileMode.Create)) { await file.CopyToAsync(stream); stream.Close(); IList <TransactionRow> transactions = CsvTransactionService.GetTransactions(fileName); this.Repository.Import(transactions, account); await WebSocketMiddleware.Broadcast(transactions.Count + " novas transações importadas!"); } return(Ok("Transação inserida com sucesso!")); } catch (Exception e) { return(BadRequest(e.Message)); } }
protected override void SendDataCore(string url, int channelCount, int itemCount) { int channelId = _channelId; for (int i = 1; i <= channelCount; ++i) { for (int j = 1; j <= itemCount; ++j) { DateTime now = DateTime.Now; Random random = new Random(); VideoStructAdapterData bike = new VideoStructAdapterData { VideoStructType = VideoStructType.非机动车, ChannelId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Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwDpWXAw\r\nenaq8gVepAq0SV32/wB4fnUDAdiDTGRlaNh9T+dSBvSDPTrjpTwba1toBdWJlnlUsVP8I/GmIYs+\r\nl4+bSnX6N/8AXqIrpV3J5NqlxBclSUBRsOR7nigZmKxkQMylTyCD2I60nFAjdhsIbq7Erq3mICUI\r\nJwD2JFTNbaurY/twrjpmyX5v1zUsaAwa4Rxq0eR62R5+tQuPEeQFvdJLg8eZE4/rQgMKK0uWv724\r\nu54PtJfE8MWdqnsR9RT/ACz6H8qoRd1bVptEEE8SQu8wYIkjY3Yx0OaxZviNerFgQWfmE4OA7bPc\r\n/wD66mwy4fHVoyIV1bD7RvH2QlQfbvUcXj2TczPp8NwycCVJNm4euG6UWGTaZcNq1tdauYxCLiXa\r\nEDZwB61YwaZJh/EuRo10srj5EcgdutS6c1hd2kHn6LphJRckQkE8A+tMZtxeF9AlSF20mAGTOQrO\r\nB/Os7xp4Z0bSfDVxc2NkscygBX3MSvPbJpAL4MHm+Cogxx++bOO/Irof7Ph/vP8AmP8ACmI//9k=", BikeType = random.Next(2, 3) }; WebSocketMiddleware.Broadcast(url, bike); VideoStructAdapterData vehicle = new VideoStructAdapterData { VideoStructType = VideoStructType.机动车, ChannelId = $"channel_{channelId}_{i}", LaneId = $"{j:D2}", Timestamp = TimeStampConvert.ToUtcTimeStamp(now), Feature = "AQAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYMY+AAAAAADo7UEAAAAAALsIQgAAAAAA2IRAAD6vQYBQmkGAfZRBAAAAAAAEEUAAAAAAgIHfQQA23EAAaFVBAAAAAAAtRUIALwNBAAAAAADV5kEAzq9BAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJxMQAAAAAAAXxZCAL1XQQAAAAAAruJBAAAAAAAAAAAA1EFAAMCUQQA9mUEAmHhAAIA1QADlK0EAAAAAAO4SQYDZWEIAhd5BABryQADQekAA0Gg/AAAAAADYiUE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QlQfbvUcXj2TczPp8NwycCVJNm4euG6UWGTaZcNq1tdauYxCLiXa\r\nEDZwB61YwaZJh/EuRo10srj5EcgdutS6c1hd2kHn6LphJRckQkE8A+tMZtxeF9AlSF20mAGTOQrO\r\nB/Os7xp4Z0bSfDVxc2NkscygBX3MSvPbJpAL4MHm+Cogxx++bOO/Irof7Ph/vP8AmP8ACmI//9k=", CarBrand = "品牌" + random.Next(1, 10), CarType = random.Next(1, 21), CarColor = random.Next(1, 21), PlateNumber = "京A0000" + random.Next(1, 9), PlateType = random.Next(1, 29) }; WebSocketMiddleware.Broadcast(url, vehicle); VideoStructAdapterData pedestrain = new VideoStructAdapterData { VideoStructType = VideoStructType.行人, ChannelId = $"channel_{channelId}_{i}", LaneId = $"{j:D2}", Timestamp = TimeStampConvert.ToUtcTimeStamp(now), Feature = "AQAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYMY+AAAAAADo7UEAAAAAALsIQgAAAAAA2IRAAD6vQYBQmkGAfZRBAAAAAAAEEUAAAAAAgIHfQQA23EAAaFVBAAAAAAAtRUIALwNBAAAAAADV5kEAzq9BAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJxMQAAAAAAAXxZCAL1XQQAAAAAAruJBAAAAAAAAAAAA1EFAAMCUQQA9mUEAmHhAAIA1QADlK0EAAAAAAO4SQYDZWEIAhd5BABryQADQekAA0Gg/AAAAAADYiUEAf9xBAL7oQYBrK0KAOkVCAAAAAAAAAAAAFJlAAAiyPwAZxUGAvKxBAAAAAAAAAAAAAAAAACxOQAAAAACAZ/NBAAAAAAC9D0IAzBNBAMniQYDh0UEAeG5BAMDHQQAAAAAAHNFAAAAAAIBOKUIAAAAAAPSRQQAAAAAA4SZCAMqYQQAAAABAihJCAJtbQQAAAAAAAAAAAA4UQQAAAAAAAAAAAJ6EQAB4xT8AAAAAgPz7QQA1nkEAAAAAAFcTQgAAAAAAAAAAAALvQIAAkkEALm1BAJ0QQQCotEAArtJAAAAA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4iJipKTlJWWl5iZmqKjpKWm\r\np6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEA\r\nAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSEx\r\nBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElK\r\nU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3\r\nuLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwDpWXAw\r\nenaq8gVepAq0SV32/wB4fnUDAdiDTGRlaNh9T+dSBvSDPTrjpTwba1toBdWJlnlUsVP8I/GmIYs+\r\nl4+bSnX6N/8AXqIrpV3J5NqlxBclSUBRsOR7nigZmKxkQMylTyCD2I60nFAjdhsIbq7Erq3mICUI\r\nJwD2JFTNbaurY/twrjpmyX5v1zUsaAwa4Rxq0eR62R5+tQuPEeQFvdJLg8eZE4/rQgMKK0uWv724\r\nu54PtJfE8MWdqnsR9RT/ACz6H8qoRd1bVptEEE8SQu8wYIkjY3Yx0OaxZviNerFgQWfmE4OA7bPc\r\n/wD66mwy4fHVoyIV1bD7RvH2QlQfbvUcXj2TczPp8NwycCVJNm4euG6UWGTaZcNq1tdauYxCLiXa\r\nEDZwB61YwaZJh/EuRo10srj5EcgdutS6c1hd2kHn6LphJRckQkE8A+tMZtxeF9AlSF20mAGTOQrO\r\nB/Os7xp4Z0bSfDVxc2NkscygBX3MSvPbJpAL4MHm+Cogxx++bOO/Irof7Ph/vP8AmP8ACmI//9k=", Sex = random.Next(1, 2), Age = random.Next(1, 5), UpperColor = random.Next(1, 9) }; WebSocketMiddleware.Broadcast(url, pedestrain); } channelId += 1; } }
protected override void ActionCore() { WebSocketMiddleware.AddUrl(_url); while (!IsCancelled()) { SendDataCore(_url, _channelCount, _itemCount); Thread.Sleep(_milliseconds); } WebSocketMiddleware.RemoveUrl(_url); }
public async Task NotAWebsocketRequestTest() { hubMock.Setup(s => s.OnConnected(new Mock <WebSocket>().Object)).Throws(new Exception("should not have been called")); contextMock.Setup(x => x.Request).Returns(requestMock.Object); contextMock.SetupGet(p => p.WebSockets).Returns(wsm.Object); wsm.SetupGet(ex => ex.IsWebSocketRequest).Returns(false); wsm.Setup(s => s.WebSocketRequestedProtocols.Count).Throws(new Exception("should not have been called")); var middleware = new WebSocketMiddleware(innerHttpContext => Task.FromResult(0), hubMock.Object); await middleware.Invoke(contextMock.Object); }
protected override void SendDataCore(string url, int channelCount, int itemCount) { DateTime now = DateTime.Now; for (int i = 1; i <= channelCount; ++i) { for (int j = 1; j <= itemCount; ++j) { int value = _random.Next(1, 300); DensityAdapterData density = new DensityAdapterData { data = new DensityData { channel_id = i, region_id = j, record_time = now.ToString("yyyyMMddHHmmss") }, type = "car_count" }; if (_mode == DataCreateMode.Random) { density.data.count = value; } else if (_mode == DataCreateMode.Sequence) { density.data.count = now.Minute; } else { density.data.count = 1; } WebSocketMiddleware.Broadcast(url, density); if (value == 1) { DensityAdapterData eventData = new DensityAdapterData { data = new DensityData { channel_id = i, region_id = j, record_time = density.data.record_time }, type = "crowd_data" }; WebSocketMiddleware.Broadcast(url, eventData); } } } }
public async Task WebSocketClosingTest() { contextMock.SetupGet(p => p.WebSockets).Returns(wsm.Object); contextMock.Setup(x => x.Request).Returns(requestMock.Object); wsm.SetupGet(ex => ex.IsWebSocketRequest).Returns(true); wsm.Setup(s => s.WebSocketRequestedProtocols.Count).Returns(0); wsm.Setup(s => s.AcceptWebSocketAsync()).Returns(Task.FromResult(websocket.Object)); websocket.SetupGet(s => s.State).Returns(WebSocketState.Open); websocket.Setup(s => s.ReceiveAsync(new ArraySegment <byte>(new byte[1024 * 4]), CancellationToken.None)) .Returns(Task.FromResult(new Mock <WebSocketReceiveResult>(123, WebSocketMessageType.Close, true).Object)); var middleware = new WebSocketMiddleware(innerHttpContext => Task.FromResult(0), hubMock.Object); var t = Task.Run(() => middleware.Invoke(contextMock.Object)); await Task.Delay(100); hubMock.Verify(m => m.OnConnected(websocket.Object)); wsm.Verify(m => m.AcceptWebSocketAsync()); hubMock.Verify(m => m.OnDisconnected(websocket.Object, WebSocketCloseStatus.NormalClosure, "Closed Peacefully")); }
protected override void SendDataCore(string url, int channelCount, int itemCount) { int channelId = _channelId; for (int i = 1; i <= channelCount; ++i) { for (int j = 1; j <= itemCount; ++j) { IOData data = new IOData { ChannelId = $"channel_{channelId}", LaneId = $"{j:D2}", Timestamp = TimeStampConvert.ToUtcTimeStamp(), Status = _random.Next(1, 100) % 2 == 1 ? 1 : 0 }; WebSocketMiddleware.Broadcast(url, data); } channelId += 1; } }
/// <summary> /// 初始化缓存 /// </summary> /// <returns>设备集合</returns> private List <DensityDevice> InitCache() { _logger.LogInformation((int)LogEvent.系统, "初始化缓存"); DensityCache.DensitiesCache.Clear(); EventCache.LastEventsCache.Clear(); WebSocketMiddleware.ClearUrl(); WebSocketMiddleware.AddUrl(EventWebSocketBlock.EventUrl); DateTime now = DateTime.Now; DateTime yesterday = now.Date.AddDays(-1); IMemoryCache memoryCache = _serviceProvider.GetRequiredService <IMemoryCache>(); using (IServiceScope serviceScope = _serviceProvider.CreateScope()) { CodesManager codesManager = serviceScope.ServiceProvider.GetRequiredService <CodesManager>(); memoryCache.InitSystemCache(codesManager.GetList()); DevicesManager devicesManager = serviceScope.ServiceProvider.GetRequiredService <DevicesManager>(); List <DensityDevice> devices = devicesManager.GetList(null, 0, 0, null, null, 0, 0).Datas; memoryCache.InitDeviceCache(devices); RoadCrossingsManager roadCrossingsManager = serviceScope.ServiceProvider.GetRequiredService <RoadCrossingsManager>(); memoryCache.InitCrossingCache(roadCrossingsManager.GetList(null, 0, 0).Datas); DensitiesManager densitiesManager = serviceScope.ServiceProvider.GetRequiredService <DensitiesManager>(); foreach (DensityDevice device in devices) { foreach (var relation in device.DensityDevice_DensityChannels) { foreach (TrafficRegion region in relation.Channel.Regions) { DensityCache.DensitiesCache.TryAdd(region.DataId, new ConcurrentQueue <TrafficDensity>(densitiesManager.QueryList(region.DataId, DateTimeLevel.Minute, yesterday, now))); WebSocketMiddleware.AddUrl($"{DensityWebSocketBlock.DensityUrl}{region.DataId}"); } } } return(devices); } }
/// <inheritdoc/> public override void OnResultExecuted(ResultExecutedContext context) { int statusCode; RealtimeDto response = new RealtimeDto { ActionNeeded = this.actionNeeded }; if (context.Result is StatusCodeResult) { statusCode = (context.Result as StatusCodeResult).StatusCode; } else if (context.Result is ObjectResult) { statusCode = (context.Result as ObjectResult).StatusCode.Value; response.Result = (context.Result as ObjectResult).Value; } else { return; // Not aply for this attribute } if (statusCode < 200 || statusCode > 299) { return; // Only Success messages apply } context.ActionDescriptor.RouteValues.TryGetValue("controller", out var controllerName); context.ActionDescriptor.RouteValues.TryGetValue("action", out var actionMethod); context.HttpContext.Request.Headers.TryGetValue("realtime-token", out var realtimeToken); response.Callback = this.callback; response.Type = this.type; response.Reducer = this.reducer ?? controllerName; response.ActionName = actionMethod; response.Method = context.HttpContext.Request.Method; var awaiter = WebSocketMiddleware.BroadcastMessage(response, realtimeToken); }
protected override void SendDataCore(string url, int channelCount, int itemCount) { DateTime now = DateTime.Now; long timestamp = TimeStampConvert.ToUtcTimeStamp(new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, 0)); Random random = new Random(); int channelId = _channelId; for (int i = 1; i <= channelCount; ++i) { FlowAdapterData flow = new FlowAdapterData { Data = new LaneAdapterData[itemCount] }; for (int j = 1; j <= itemCount; ++j) { if (_mode == DataCreateMode.Random) { flow.Data[j - 1] = new LaneAdapterData { ChannelId = $"channel_{channelId}", LaneId = $"{j:D2}", Timestamp = timestamp, Bikes = random.Next(1, 10), Buss = random.Next(1, 10), Cars = random.Next(1, 10), Motorcycles = random.Next(1, 10), Persons = random.Next(1, 10), Tricycles = random.Next(1, 10), Trucks = random.Next(1, 10), Vans = random.Next(1, 10), AverageSpeed = random.Next(1, 10), HeadSpace = random.Next(1, 10), HeadDistance = random.Next(1, 10), Occupancy = random.Next(1, 100), TimeOccupancy = random.Next(1, 100), TrafficStatus = (TrafficStatus)random.Next(1, 5) }; } else if (_mode == DataCreateMode.Sequence) { flow.Data[j - 1] = new LaneAdapterData { ChannelId = $"channel_{channelId}", LaneId = $"{j:D2}", Timestamp = timestamp, Bikes = now.Minute, Buss = now.Minute, Cars = now.Minute, Motorcycles = now.Minute, Persons = now.Minute, Tricycles = now.Minute, Trucks = now.Minute, Vans = now.Minute, AverageSpeed = now.Minute, HeadSpace = now.Minute, HeadDistance = now.Minute, Occupancy = now.Minute, TimeOccupancy = now.Minute, TrafficStatus = TrafficStatus.通畅 }; } else { flow.Data[j - 1] = new LaneAdapterData { ChannelId = $"channel_{channelId}", LaneId = $"{j:D2}", Timestamp = timestamp, Bikes = 1, Buss = 1, Cars = 1, Motorcycles = 1, Persons = 1, Tricycles = 1, Trucks = 1, Vans = 1, AverageSpeed = 1, HeadSpace = 1, HeadDistance = 1, Occupancy = 1, TimeOccupancy = 1, TrafficStatus = TrafficStatus.通畅 }; } } WebSocketMiddleware.Broadcast(url, flow); channelId += 1; } }
public Application() { var wsOptions = new WebSocketOptions(); wsMiddleware = new WebSocketMiddleware(continueRequest, new OptionsWrapper <WebSocketOptions>(wsOptions)); }
protected override void Handle(TrafficDensity data) { WebSocketMiddleware.Broadcast($"{DensityUrl}{data.DataId}", data); }
protected override void Handle(TrafficEvent data) { _memoryCache.FillEvent(data); WebSocketMiddleware.Broadcast(EventUrl, data); }