Create a Signal R Hub OnConnected with startCalled
up vote
0
down vote
favorite
My C# method 'OnConnected()' in my Singal R hub class calls
Clients.All.setConnectionStatus(profileId, true);
with every page load and login!
With my 'OnDisconnected(bool stopCalled)', if there is a logout I check for 'stopCalled', which gets set to false with a logout and true for a page load. Is there anything I can do in the 'OnConnected' method to check the same thing? ex. 'bool startCalled' which just looks for a login and not a page load!
Because currently, with every page load, I have to send out a 'setConnectionStatus', which is seemingly redundant and an overkill.
Isn't there a way to just look for a login similarly with the 'OnDisconnected' ?
public override Task OnConnected()
{
string profileId = Context.User.Identity.Name;
_connections.Add(profileId, Context.ConnectionId);
Clients.All.setConnectionStatus(profileId, true);
return base.OnConnected();
}
public override Task OnDisconnected(bool stopCalled)
{
string profileId = Context.User.Identity.Name;
_connections.Remove(profileId, Context.ConnectionId);
if (stopCalled == false) // log off only
Clients.All.setConnectionStatus(profileId, false);
return base.OnDisconnected(stopCalled);
}
c# asp.net-mvc signalr signalr-hub
add a comment |
up vote
0
down vote
favorite
My C# method 'OnConnected()' in my Singal R hub class calls
Clients.All.setConnectionStatus(profileId, true);
with every page load and login!
With my 'OnDisconnected(bool stopCalled)', if there is a logout I check for 'stopCalled', which gets set to false with a logout and true for a page load. Is there anything I can do in the 'OnConnected' method to check the same thing? ex. 'bool startCalled' which just looks for a login and not a page load!
Because currently, with every page load, I have to send out a 'setConnectionStatus', which is seemingly redundant and an overkill.
Isn't there a way to just look for a login similarly with the 'OnDisconnected' ?
public override Task OnConnected()
{
string profileId = Context.User.Identity.Name;
_connections.Add(profileId, Context.ConnectionId);
Clients.All.setConnectionStatus(profileId, true);
return base.OnConnected();
}
public override Task OnDisconnected(bool stopCalled)
{
string profileId = Context.User.Identity.Name;
_connections.Remove(profileId, Context.ConnectionId);
if (stopCalled == false) // log off only
Clients.All.setConnectionStatus(profileId, false);
return base.OnDisconnected(stopCalled);
}
c# asp.net-mvc signalr signalr-hub
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
My C# method 'OnConnected()' in my Singal R hub class calls
Clients.All.setConnectionStatus(profileId, true);
with every page load and login!
With my 'OnDisconnected(bool stopCalled)', if there is a logout I check for 'stopCalled', which gets set to false with a logout and true for a page load. Is there anything I can do in the 'OnConnected' method to check the same thing? ex. 'bool startCalled' which just looks for a login and not a page load!
Because currently, with every page load, I have to send out a 'setConnectionStatus', which is seemingly redundant and an overkill.
Isn't there a way to just look for a login similarly with the 'OnDisconnected' ?
public override Task OnConnected()
{
string profileId = Context.User.Identity.Name;
_connections.Add(profileId, Context.ConnectionId);
Clients.All.setConnectionStatus(profileId, true);
return base.OnConnected();
}
public override Task OnDisconnected(bool stopCalled)
{
string profileId = Context.User.Identity.Name;
_connections.Remove(profileId, Context.ConnectionId);
if (stopCalled == false) // log off only
Clients.All.setConnectionStatus(profileId, false);
return base.OnDisconnected(stopCalled);
}
c# asp.net-mvc signalr signalr-hub
My C# method 'OnConnected()' in my Singal R hub class calls
Clients.All.setConnectionStatus(profileId, true);
with every page load and login!
With my 'OnDisconnected(bool stopCalled)', if there is a logout I check for 'stopCalled', which gets set to false with a logout and true for a page load. Is there anything I can do in the 'OnConnected' method to check the same thing? ex. 'bool startCalled' which just looks for a login and not a page load!
Because currently, with every page load, I have to send out a 'setConnectionStatus', which is seemingly redundant and an overkill.
Isn't there a way to just look for a login similarly with the 'OnDisconnected' ?
public override Task OnConnected()
{
string profileId = Context.User.Identity.Name;
_connections.Add(profileId, Context.ConnectionId);
Clients.All.setConnectionStatus(profileId, true);
return base.OnConnected();
}
public override Task OnDisconnected(bool stopCalled)
{
string profileId = Context.User.Identity.Name;
_connections.Remove(profileId, Context.ConnectionId);
if (stopCalled == false) // log off only
Clients.All.setConnectionStatus(profileId, false);
return base.OnDisconnected(stopCalled);
}
c# asp.net-mvc signalr signalr-hub
c# asp.net-mvc signalr signalr-hub
edited Nov 10 at 22:16
asked Nov 8 at 23:45
user1186050
2,105933108
2,105933108
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53217834%2fcreate-a-signal-r-hub-onconnected-with-startcalled%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown