How to join a group using SignalR
Tag : chash , By : alchemist
Date : March 29 2020, 07:55 AM
it helps some times You can't. If you could join a group from javascript then anyone may use your code to join any group which breaks security. If you really need to do that - create a method on the server side that takes a group name as parameter and adds the client to the group. public void JoinGroup(string groupName)
{
this.Groups.Add(this.Context.ConnectionId, groupName);
}
eventHub.server.joinGroup("my-awsm-group");
|
SignalR join/leave group doesn't work correctly
Date : November 23 2020, 12:01 PM
Hope that helps The group management methods (add and remove) are async. If you don't await the returned task then send to the group immediately after you have a race condition such that the client you just added might not receive the message. Also, you should never call .Wait() from in a hub method. Make the hub method async and await it instead. readonly ISprayBroadcaster _sprayBroadcaster;
readonly IWorkRecordRepository _workRecordRepository;
public SprayHub(ISprayBroadcaster sprayBroadcaster, IWorkRecordRepository workRecordRepository)
{
_sprayBroadcaster = sprayBroadcaster;
_workRecordRepository = workRecordRepository;
}
public async Task Broadcast(string name)
{
await Process.DataProcess(_workRecordRepository, Clients, name);
}
public async Task SwapGroup(string previousGroup, string newGroup)
{
await Groups.Remove(Context.ConnectionId, previousGroup);
await Groups.Add(Context.ConnectionId, newGroup);
}
public async Task JoinGroup(string groupName)
{
await Groups.Add(Context.ConnectionId, groupName);
}
|
How to join a client to group in MVC using signalR
Date : March 29 2020, 07:55 AM
Does that help I found the problem. my javascript had(I just also noticed the javascript I wrote here was a previous version): <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
var hub = $.Connection.gamesHub;
|
How to join group using SignalR Objective-C?
Date : March 29 2020, 07:55 AM
To fix the issue you can do Joining to a group is a server side thing. You need to create a hub method (server side) that adds a connection to a group and then invoke this hub method from the client. Take a look at this article for more details.
|
Join group on the js - SignalR 1.1.4
Date : March 29 2020, 07:55 AM
hope this fix your issue I was able to achieve what I wanted by following this tutorialin short: public async Task JoinGroup(string group)
{
if (connectionsNgroup.ContainsKey(Context.ConnectionId))
{
await Groups.RemoveFromGroupAsync(Context.ConnectionId, connectionsNgroup[Context.ConnectionId]);
connectionsNgroup.Remove(Context.ConnectionId);
}
connectionsNgroup.Add(Context.ConnectionId, group);
await Groups.AddToGroupAsync(Context.ConnectionId, group);
}
this.state.hubConnection.invoke("JoinGroup", this.state.groupName).catch(err => console.error(err));
|