天道酬勤,学无止境

signalr-hub

在 Android 中设置 Signal R:崩溃/挂起问题(Setting up Signal R in Android: Crash/Hung Issue)

问题 我按照本教程为我的 Android 应用程序设置了一个 .NET 后端以实现 Signal R。我设置了一个 SignalR 自托管后端。 这是我在控制台项目中的后端代码: namespace SignalRSelfHost { class Program { static void Main(string[] args) { // This will *ONLY* bind to localhost, if you want to bind to all addresses // use http://*:8080 to bind to all addresses. // See http://msdn.microsoft.com/en-us/library/system.net.httplistener.aspx // for more information. string url = "http://localhost:8080"; using (WebApp.Start(url)) { Console.WriteLine("Server running on {0}", url); Console.ReadLine(); } } } class Startup { public void Configuration(IAppBuilder app) { app

2021-06-23 15:13:06    分类:技术分享    android   signalr   azure-mobile-services   signalr-hub   signalr.client

Context is null in SignalR hub

I have a Web Forms application and testing to see how SignalR works for one of my requirement. My hub code: using System; using System.Collections.Generic; using System.Linq; using System.Web; using Microsoft.AspNet.SignalR; namespace SignalRTest.Hubs { public class NotificationHub : Hub { public static readonly System.Timers.Timer _Timer = new System.Timers.Timer(); public NotificationHub() { var myInfo = Context.QueryString["myInfo"]; _Timer.Interval = 2000; _Timer.Elapsed += TimerElapsed; _Timer.Start(); } void TimerElapsed(object sender, System.Timers.ElapsedEventArgs e) { Random rnd = new

2021-06-23 06:46:25    分类:问答    c#   signalr   signalr-hub   signalr.client

Instantiate SignalR Hub Object With IHubContext

It seems like a big use for SignalR Hubs is to display the actions of one client to all of the other clients. What I hope to use SignalR for is when a certain event happens in my server side code, I want to instantiate a hub object and invoke one of its methods to communicate with all of the clients. If you see my previous post (Route To Take With SqlDependency OnChange), I would like to do this in the OnChange method of SqlDependency. Upon researching it I have found some people talk about using an IHubContext object, though I haven't found many examples of instantiation and actual sending

2021-06-22 11:25:53    分类:问答    c#   asp.net   signalr   signalr-hub   sqldependency

向信号器中的特定用户发送消息(Send message to specific user in signalr)

问题 我有一个 signalR 服务器(控制台应用程序)和一个客户端应用程序(Asp.net MVC5) 如何向 OAuth 成员身份中的特定用户发送消息。 实际上我无法从集线器请求上下文中解析发件人用户。 Context.User.Identity.Name 我的中心 public class UserHub : Hub { #region Hub Methods public void LoggedIn(string userName, string uniqueId, string ip) { Clients.All.userLoggedIn(userName, uniqueId, ip); } public void LoggedOut(string userName, string uniqueId, string ip) { var t = ClaimsPrincipal.Current.Identity.Name; Clients.All.userLoggedOut(userName, uniqueId, ip); } public void SendMessage(string sendFromId, string userId, string sendFromName, string userName, string message) { Clients.User

2021-06-22 04:58:39    分类:技术分享    c#   asp.net   signalr   signalr-hub

SignalR 客户端如何在开始连接时设置用户?(SignalR Client How to Set user when start connection?)

问题 服务器端: public override Task OnConnected() { var connectionId = Context.ConnectionId; var user = Context.User.Identity.Name; // Context.User is NULL return base.OnConnected(); } 客户端(在控制台项目中): IHubProxy _hub; string url = @"http://localhost:8080/"; var connection = new HubConnection(url); _hub = connection.CreateHubProxy("TestHub"); connection.Start().Wait(); 当客户端连接到服务器时,我想知道userName和connectionId之间的映射,但是Context.User为NULL。 如何在客户端设置此值? 回答1 使用查询字符串传递您的用户名。 客户 首先设置查询字符串 string url = @"http://localhost:8080/"; var connection = new HubConnection(url); _hub = connection.CreateHubProxy("TestHub")

2021-06-21 19:42:06    分类:技术分享    javascript   c#   signalr   signalr-hub   signalr.client

SignalR 客户端如何在开始连接时设置用户?(SignalR Client How to Set user when start connection?)

问题 服务器端: public override Task OnConnected() { var connectionId = Context.ConnectionId; var user = Context.User.Identity.Name; // Context.User is NULL return base.OnConnected(); } 客户端(在控制台项目中): IHubProxy _hub; string url = @"http://localhost:8080/"; var connection = new HubConnection(url); _hub = connection.CreateHubProxy("TestHub"); connection.Start().Wait(); 当客户端连接到服务器时,我想知道userName和connectionId之间的映射,但是Context.User为NULL。 如何在客户端设置此值? 回答1 使用查询字符串传递您的用户名。 客户 首先设置查询字符串 string url = @"http://localhost:8080/"; var connection = new HubConnection(url); _hub = connection.CreateHubProxy("TestHub")

2021-06-21 19:40:48    分类:技术分享    javascript   c#   signalr   signalr-hub   signalr.client

SignalR cannot connect to Azure Redis on SSL

I am currently hosting my redis cache server on Azure, and have signalR relying on it as the backbone using the following... GlobalHost.DependencyResolver.UseRedis("Server",port,"password","eventKey"); This works find on port 6379 (non-SSL) but my chat app breaks when I try to connect to the SSL port (6380) of my Azure Redis server, and the hub is never started. What could be the cause of this issue? Or am I doing something wrong? This is the error that appears on /signalr/connect in my browser net::ERR_CONNECTION_RESET

2021-06-15 07:45:19    分类:问答    redis   signalr   signalr-hub   signalr-backplane   azure-redis-cache

SignalR request pipeline, Hub lifetime

I am starting on signalR with asp.net webapi, and I am trying to understand the whole signalR request/connection pipeline and what is the lifetime of the hub and who creates and dispose the hub instance (does it gets created on every communication between client and server?) One of the reason is that we need to understand how we should be using an IoC contain in signalR request scenario, how we control the lifetime of the dependency correct specifically the ISession or DBContext.

2021-06-14 15:58:09    分类:问答    signalr   signalr-hub

Get full URL inside SignalR hub

I'm developing an user tracking solution using SignalR, as a fun project to learn SignalR, for ASP.NET MVC applications. Currently i can track logged users and how long are they on a specific page. If they move to another page i track that also and the timer that SignalR is updating resets... Many other features are implemented or partially implemented. The problem i'm facing is how to get the full url Controller/Action/Parameters inside SignalR hub? When i use HttpContext.Current.Request.Url the url is always /signalr/connect. NOTE: var hub = $.connection.myHub; $.connection.hub.start(); is

2021-06-13 20:12:00    分类:问答    asp.net   asp.net-mvc-4   signalr   signalr-hub

SignalR 和 Castle Windsor 的适当 Hub 依赖项生命周期管理(Proper Hub dependency lifetime management for SignalR and Castle Windsor)

问题 我有一些 SignalR 集线器,它们可能需要访问一些瞬态和单例依赖项。 挂钩集线器的创建很容易并且工作得很好,但是 SignalR 对创建的集线器执行自己的 Dispose() 调用,而不是通知依赖项解析器并让它参与处理。 如果依赖项是注册的单例,这不是什么大问题,但是如果它们被注册为瞬态,那么它们将永远不会被处理(如果需要的话)并且 Windsor 将保持它们活动直到收集 Windsor 容器(当无论如何,Web 服务器正在关闭)。 我看到了几种可能的处理方法...... a) 这里有人指出了一种方法来继承 SignalR 的 HubDispatcher 类,以便它可以进行适当的处​​理。 它不是 SignalR 的标准 DependencyResolver 的一部分,因此这可能很困难/不可能 b) SignalR 中的其他一些类,在管道的其他地方,可以被覆盖或轻松替换,以便我们可以子类化 HubDispatcher 并确保使用子类。 据我所知,这必须是 Owin 中间件类 HubDispatcherMiddleware。 有没有办法强制 Owin 不注册这个类,而是注册我自己的这个版本(反过来使用我自己的 HubDispatcher)? c) 有一些方法可以拦截 SignalR 在我的 Hub 类上进行的 Dispose() 调用,以便可以将调用返回到 Windsor

2021-06-11 14:30:55    分类:技术分享    inversion-of-control   signalr   castle-windsor   signalr-hub