public async Task Group([HttpTrigger(AuthorizationLevel.Anonymous, "post")] HttpRequest req) { using (var rd = new StreamReader(req.Body)) { var groupAction = JsonConvert.DeserializeObject <SignalRGroupAction>(await rd.ReadToEndAsync()); if (!string.IsNullOrEmpty(groupAction.ConnectionId)) { switch (groupAction.Action) { case GroupAction.Add: await Groups.AddToGroupAsync(groupAction.ConnectionId, groupAction.GroupName); break; case GroupAction.Remove: await Groups.RemoveFromGroupAsync(groupAction.ConnectionId, groupAction.GroupName); break; } } else if (!string.IsNullOrEmpty(groupAction.UserId)) { switch (groupAction.Action) { case GroupAction.Add: await UserGroups.AddToGroupAsync(groupAction.UserId, groupAction.GroupName); break; case GroupAction.Remove: await UserGroups.RemoveFromGroupAsync(groupAction.UserId, groupAction.GroupName); break; case GroupAction.RemoveAll: await UserGroups.RemoveFromAllGroupsAsync(groupAction.UserId); break; } } } }
public async Task JoinUserToGroup([SignalRTrigger] InvocationContext invocationContext, string userName, string groupName) { await UserGroups.AddToGroupAsync(userName, groupName); }