c# - List of opened connections in SignalR? -
how can list of opened connections signalr without sending them "ping" or manual registering them own list?
update: or number of clients message sent hub. want know how many responses should wait (without waiting whole timeout).
(since, signalr not support return values when calling clients hub, collecting results message clients sending hub.)
clarification: assume signalr must know connections sending message.
you can store user's id onconnected , remove on disconnect. see this example using database persist connected ids
protected task onconnected(irequest request, string connectionid){ var context=new dbcontext(); context.connections.add(connectionid); context.save(); } protected task ondisconnected(irequest request, string connectionid){ var context=new dbcontext(); var id=context.connections.firstordefault(e=>e.connectionid==connectionid); context.connections.remove(id); context.save(); }
then everywhere need access list of connected ids, request db.
Comments
Post a Comment