Example #1
0
        public async Task AssignToProjectAsync(string projectId, IPrincipal user, string connectionId)
        {
            if (!activeSessions.ContainsKey(projectId))
            {
                await AddCollabSessionAsync(projectId);
            }

            CollaboratorInfo collaborator = null;

            if (!user.Identity.IsAuthenticated)
            {
                AddCollaborator(projectId, CreateAnonymousCollaborator(connectionId));
            }
            else
            {
                collaborator = activeSessions[projectId].Collaborators.SingleOrDefault(
                    clb => clb.UserName == user.Identity.Name
                    );
                if (collaborator == null)
                {
                    AddCollaborator(projectId, CreateAuthenticatedCollaborator(user, connectionId));
                }
                else
                {
                    collaborator.ConnectionIds.Add(connectionId);
                }
            }

            Volatile.Read(ref Connected)?.Invoke(
                this, new ConnToProjectEventArgs
            {
                ProjectId    = projectId,
                ConnectionId = connectionId,
                User         = user
            });
        }
Example #2
0
 private void AddCollaborator(string projectId, CollaboratorInfo clbInfo)
 {
     activeSessions[projectId].Collaborators.Add(clbInfo);
 }