signalr-hub

Proper Hub dependency lifetime management for SignalR and Castle Windsor

允我心安 提交于 2019-12-03 08:10:52
问题 I have some SignalR hubs which may need to access some transient and singleton dependencies. Hooking the creation of the Hub is easy and works just fine however SignalR does its own Dispose() call on the created Hub rather than notifying the dependency resolver and letting it get involved in the disposal. This isn't such a big deal if the dependencies are registered singletons, but if they're registered as transients then they'll never get disposed (if that was required) and Windsor will keep

SignalR .Net Client - Unexpected character encountered while parsing value

烈酒焚心 提交于 2019-12-03 07:50:52
I'm trying to set up a .Net client to send messages to my signalR hub from my service layer. I'm following this guide: http://www.asp.net/signalr/overview/signalr-20/hubs-api/hubs-api-guide-net-client#callserver This is what I have: _hubConnection = new HubConnection(_baseUrl); // "http://localhost:3806" _hubProxy = _hubConnection.CreateHubProxy("AppHub"); _hubConnection.Start().Wait(); The hub lives inside of the same project - it's an MVC application with forms authentication. I can never get past the .Wait() call, it always errors out with the following: Message=Unexpected character

SignalR Client How to Set user when start connection?

孤者浪人 提交于 2019-12-03 07:17:01
Server side: public override Task OnConnected() { var connectionId = Context.ConnectionId; var user = Context.User.Identity.Name; // Context.User is NULL return base.OnConnected(); } Client side (in Console project): IHubProxy _hub; string url = @"http://localhost:8080/"; var connection = new HubConnection(url); _hub = connection.CreateHubProxy("TestHub"); connection.Start().Wait(); When the client connect to the server, I want to know the map between userName and connectionId, But Context.User is NULL. How do I set this value in the client side? Pass your username using query string. Client

Send message to specific user in signalr

醉酒当歌 提交于 2019-12-03 03:21:44
问题 I have a signalR Server(Console Application) and a client application(Asp.net MVC5) How I can send message to specific user in OAuth Membership. Actually I can't resolve sender user from hub request context with. Context.User.Identity.Name My Hub 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 =

Proper Hub dependency lifetime management for SignalR and Castle Windsor

走远了吗. 提交于 2019-12-02 21:47:15
I have some SignalR hubs which may need to access some transient and singleton dependencies. Hooking the creation of the Hub is easy and works just fine however SignalR does its own Dispose() call on the created Hub rather than notifying the dependency resolver and letting it get involved in the disposal. This isn't such a big deal if the dependencies are registered singletons, but if they're registered as transients then they'll never get disposed (if that was required) and Windsor will keep them alive until the Windsor container is collected (when the web server is shutting down anyway). I

SignalR & require.js configuration

徘徊边缘 提交于 2019-12-02 21:03:50
I'm incorporating SignalR into a project where I'm already using require.js to handle my scripts dependencies. I'm having a little trouble making sure "/signalr/hubs" is called after "jquery.signalR-1.1.2" loads. I got it to work, but I'm wondering if there is a better alternative out there. This is what I have: require(["signalr"], function () { require(["noext!/signalr/hubs"], function () { //initialize and work with the hub here } } Is there a way I can create a shim here to establish the dependency between signalr/hubs and the signalr script? Thanks! This works for me with SignalR 1.1.2:

Send message to specific user in signalr

血红的双手。 提交于 2019-12-02 17:48:36
I have a signalR Server(Console Application) and a client application(Asp.net MVC5) How I can send message to specific user in OAuth Membership. Actually I can't resolve sender user from hub request context with. Context.User.Identity.Name My Hub 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

SignalR not working when system is ideal for some time

夙愿已清 提交于 2019-12-02 16:38:30
问题 $.connection.myHubName.client.disconnect(function () { $.connection.hub.start(); }); on hub.start(); server is started but still it working properly 回答1: The correct method is hanging off the hub connection itself not the hub (so not the client object). $.connection.hub.disconnected(function () { console.log('We are currently experiencing difficulties with the connection.') }); 来源: https://stackoverflow.com/questions/47504489/signalr-not-working-when-system-is-ideal-for-some-time

Setting up Signal R in Android: Crash/Hung Issue

瘦欲@ 提交于 2019-12-02 08:21:01
问题 I followed THIS tutorial to set up a .NET Backend for my Android app to implement Signal R. I set up a SignalR Self-Hosted backend. Here's my Backend Code in a Console Project: 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

Setting up Signal R in Android: Crash/Hung Issue

杀马特。学长 韩版系。学妹 提交于 2019-12-02 05:15:27
I followed THIS tutorial to set up a .NET Backend for my Android app to implement Signal R. I set up a SignalR Self-Hosted backend. Here's my Backend Code in a Console Project: 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);