i have signalr hub function this
public void sendsurveynote(int surveyid,list<string> users){} here want add users of list group "survey_" + surveyid sending group message. have user id joining group requires connection id. how manage that. wonder performance issue send each user message without group?
i call function above when add new survey this
private static hubconnection hubconnection = new hubconnection(configurationmanager.appsettings["baseurl"]); private static ihubproxy hubproxy = hubconnection.createhubproxy("myhub"); await hubconnection.start(); hubproxy.invoke("sendsurveynote", model.id, users); thanks
you have access connection id within context. you'll want establish groups within onconnected. observe following implementation on hub, call myhub. we'll group context.user.identity.name establish unique group per user, value wish group by.
public class myhub: hub { public override task onconnected() { groups.add(context.connectionid, context.user.identity.name) return base.onconnected(); } } see working groups in signalr more information
Comments
Post a Comment