dsuryd / dotNetify

Simple, lightweight, yet powerful way to build real-time web apps.
https://dotnetify.net
Other
1.17k stars 164 forks source link

How to get connected user count in dotnetify multicastvm class? #163

Closed muratoner closed 5 years ago

muratoner commented 5 years ago

I'm using dotnetify in .net core and react-native projects but i have a problem and my problem this;

I want take connected user count in dotnetify but this proccess very basic in signalr. I don't know. How to solve this problem from dotnetify? Please help.

dsuryd commented 5 years ago

You have to write the logic to keep track of this yourself. SignalR has no API to provide # of connected users in a group.

muratoner commented 5 years ago

Yes, you are right but signalr has "onconnected" and "ondisconnected" metod i'm write simple code and solve my problem in signalr. For example 'im increasing "connectedUserCount" variable when triggered "onconnected" signalr metod and i'm decreasing "connectedUserCount" variable when triggered "ondisconnected" signalr metod.

dsuryd commented 5 years ago

Counting the connections only works with 1 server, not when SignalR is scaled out. There is no way to get connection info across multiple servers (https://github.com/aspnet/SignalR/issues/1418). Also, the assumption that 1 user equals 1 connection is not valid.

A reliable solution would be to create an AddUser command in your MulticastVM instance for the clients to invoke, and manage your own user list separately, e.g. with a Redis cache. Detection of disconnection can be done by overriding the Dispose method (see discussion in issue #151).

muratoner commented 5 years ago

i'm understood, thanks for help.