Pergunta

I have different groups of users to which i need to send data. I could have used hubs concept here but the only SignalR Android client library "SignalA" https://github.com/erizet/SignalA doesnt have implementation for hubs so i had to use Persisted Connections and its group concept. Now i see this OnConnected method on the SignalR documentation site

protected override Task OnConnected(IRequest request, string connectionId)
{
    return Groups.Add(connectionId, "foo");
}

I want the user to be able to join different groups, so when he connects he will be passing a group name to which he wants to be added. How can i pass the group name on the client side as well as receive it in the above method instead of using a hardcoded "foo"?

I would also be very happy if anyone can point me to a SignalR java client library which has hubs implementation, as I failed to find any.

Thanks

Foi útil?

Solução

You have 2 options:

  1. Pass query string parameters (if the java client supports it) as part of the connection information. That way you can pass the list of groups via the query string to join. If you do this then you can use request.QueryString to access the query string and do whatever processing you need.
  2. After connecting you can send a message to the server and handle OnReceived and pass a list of groups.

Either one works.

Outras dicas

I know it's an old question but I think it's worth mentioning that SignalA now supports hubs.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top