c# - Mapping SignalR Users to Connections in Groups -
how can add/remove user group using userid
groups.add(userid,"groupname") that use in database instead of using connectionid
groups.add(connectionid,"groupname") i created mapping here! using user id provider method , able this
clients.users(userid).sendmessage("asa") but
groups.add(userid,"groupname") it not working. how can make groups.add(userid,"groupname") work? there special mapping don't know or using 1 wrong?
it not possible add userid group. should use connectionid. depending of needs can use 1 of approaches described in the link provided.
for example, can add each connection group named userid:
groups.add(context.connectionid, userid); and can send messages specified user:
clients.group(userid).sendmessage("asa"); another use case may include determining userid in onconnected method , adding user needed group connectionid:
var groupname = getgroupnamebyuserid(userid); groups.add(context.connectionid, groupname); ... clients.group(groupname).sendmessage("asa");
Comments
Post a Comment