signalr

How to dynamically add hub to SignalR and have different scopes

点点圈 提交于 2019-12-05 04:21:28
问题 I'm attempting to build a Dashboard with widgets (built as directives). I'd like to at a later stage have the ability to dynamically add widgets, but I'd only like the active widgets (and hubs) to receive data, thus if a widget isn't active i don't want the hub to be registered. Eg for the duration of the user using the app there will be a global signalR context, as well as page specific ones, which will be spawned/destroyed as needed. This is my best try ATM... which isn't working factory

ASP.NET Core SignalR中的流式传输

寵の児 提交于 2019-12-05 04:13:58
原文: ASP.NET Core SignalR中的流式传输 什么是流式传输? # 流式传输是这一种以稳定持续流的形式传输数据的技术。 流式传输的使用场景 # 有些场景中,服务器返回的数据量较大,等待时间较长,客户端不得不等待服务器返回所有数据后,再进行相应的操作。这时候使用流式传输,可以将服务器数据碎片化,当每个数据碎片读取完成之后,就只传输完成的部分,而不需要等待所有数据都读取完成。 如何在ASP.NET Core SignalR中启用流式传输 # 在ASP.NET Core SignalR中当一个 Hub 方法的返回值是 ChannelReader 或者 Task<ChannelReader > , 这个 Hub 方法自动就会变成一个流式传输 Hub 方法。 下面我们来做了一个简单的例子 创建一个ASP.NET Core Web应用 # 首先我们使用Visual Studio 2017创建一个ASP.NET Core Web应用程序。 选择创建ASP.NET Core 2.1的Web Application 创建Hub # 下面我们添加一个 StreamHub 类,代码如下 Copypublic class StreamHub : Hub { public ChannelReader<int> DelayCounter(int delay) { var channel =

玩转ASP.NET Core中的日志组件

China☆狼群 提交于 2019-12-05 04:13:01
原文: 玩转ASP.NET Core中的日志组件 简介 # 日志组件 ,作为程序员使用频率最高的组件,给程序员开发调试程序提供了必要的信息。ASP.NET Core中内置了一个通用日志接口 ILogger ,并实现了多种内置的日志提供器,例如 Console Debug EventSource EventLog TraceSource Azure App Service 除了内置的日志提供器,ASP.NET Core还支持了多种第三方日志工具,例如 elmah.io Gelf JSNLog KissLog.net Loggr NLog Serilog 开发人员在ASP.Net Core中可以自由指定日志提供器,并将日志发送到指定的位置。 本篇博文中,我们将由浅入深的介绍ASP.Net Core中通用日志接口,最后我们将实现一些自定义的日志提供器(Log Provider)。 使用系统提供的内置日志提供器 # 日志级别(Log Level) # ASP.NET Core中提供了6种日志级别,分别是Trace, Debug, Information, Warning, Error, Critical。以下是他们的具体使用场景 日志级别 常用场景 Trace 记录一些对程序员调试问题有帮助的信息, 其中可能包含一些敏感信息, 所以应该避免在 生产环境中启用Trace日志 Debug

How to get a list of connected clients on SignalR

心已入冬 提交于 2019-12-05 04:08:57
I am quite new to SignalR. My first assignment is to make simple chat app. I have been browsing and reading and finally made a page where you come and chat and it works fine. Now I need to show a list of connected clients. To achieve this I have wrote the following code. This is my HUB. public class ChatHub: Hub { chatEntities dc = new chatEntities(); public void Send(string message,string clientName) { Clients.addMessage(message,clientName); } // I want to save the user into my database, when they join public void Joined(string userId,string userName) { CurrentChattingUsers cu = new

Check authorize in SignalR attribute

左心房为你撑大大i 提交于 2019-12-05 03:28:06
i have some services on ServiceStack and use SignalR in this project. And now, i would like to secure hub connection (access only for authenticated users), but i use ServiceStack framework authentication.. (not asp.net authentication) and ServiceStack's sessions (write AuthUserId ih this session and authentication flag). So, when user trying connect to the hub -- hub must to check authentication... (yes, i can request Cookies from Hub (method OnConnected, for example), but SignalR check authentication in Authorize Attribute - and i must do it in this class (not in hub) ( http://www.asp.net

SignalR authentication with javascript client

不羁岁月 提交于 2019-12-05 03:23:56
问题 I was playing with the open authentication in MVC5 and SignalR . I use a javascript client to call a simple server method on SignalR and receive a reply from Server. It works well, but if I add the [Authorize] tag, it does not even call the server method (did not get any response while debugging). My assumption was the server will use the Authentication mechanism to challenge the client. Am I missing anything? Do I have to manually authenticate the user from the client side and if so how do I

Signalr assembly loading issue OWIN

荒凉一梦 提交于 2019-12-05 03:22:16
I'm getting this error when attempting to load classes in the Microsoft.AspNet.SignalR.Owin assembly. The exception is thrown after execution leaves the Configuration method in startup.cs . I've registered a Global Exception Handler to try and catch the exception but it is not being caught. public async override Task HandleAsync(ExceptionHandlerContext context, CancellationToken cancellationToken) { var exception = context.Exception; const string genericErrorMessage = "An unexpected error occured"; var response = context.Request.CreateResponse(HttpStatusCode.InternalServerError, new { Message

SignalR WebRTC WebSocket is already in CLOSING or CLOSED state

谁说胖子不能爱 提交于 2019-12-05 02:48:20
I wanted to take a test run of the simplest implementation of SignalR and WebRTC. I hosted the code in https://github.com/foyzulkarim/WebRtc I made two different files "index.html" and "index1.html". In index.html I broadcasted a video file through signalr and it went very well. But when I just replace existing video file with WebCam's feed, it started getting error. After running couple of second I start getting this error "WebSocket is already in CLOSING or CLOSED state." I tried to throttle but no change, still get the error. Any idea why it might happening? Error image You can check the

RavenDB and SignalR Nuget Package Dependency Conflict

天涯浪子 提交于 2019-12-05 02:30:18
Basic conflict. SignalR wants Newtonsoft.Json version 4.0.7 or higher while RavenDB wants version equal to 4.0.5. Which obviously means they can't be installed side by side. So aside from downloading the source code from one of them and getting the dependencies figured out locally then have to check in the binary created from that, is there a possible way to keep the dependencies managed with NuGet, and maybe just forward the DLL Calls (like Mvc does with each new version for example)? We were running into the same issue a few days ago and this is a nasty one. We found that you can't keep the

SignalR and NServiceBus in a WebFarm

こ雲淡風輕ζ 提交于 2019-12-05 02:21:48
问题 I am trying to understand if/how this works. Can SignalR and NServiceBus be used together to support full duplex on a web farm where the request could be sent from a server then later the response would come back but the user may be on another server. The use case for this would be a user submits a form which then takes a while to process say 3-5 minutes. During that time the user is doing other things and could be switching between servers due to load balancing. Once the process is complete