Esempio n. 1
0
        public async Task OpenDirectMessage(string username)
        {
            try
            {
                string uid = UserManagement.GetIdFromUsername(username);
                if (uid.Equals(Context.ConnectionId))
                {
                    await Clients.Caller.SendAsync("SameUserError");

                    return;
                }
                string   groupname = Context.ConnectionId + uid;
                string[] v         = { Context.ConnectionId, uid };
                await Groups.AddToGroupAsync(Context.ConnectionId, groupname);

                await Groups.AddToGroupAsync(uid, groupname);

                await Clients.Clients(v).SendAsync("UpdateGroups", groupname);
            }
            catch (UserManagement.UserDoesntExistException e)
            {
                await Clients.Caller.SendAsync("UserDoesntExistError");
            }
        }
Esempio n. 2
0
 public async Task SendMessage(string room, string msg)
 {
     await Clients.Group(room).SendAsync("ReceiveMessage", room, UserManagement.GetUsername(Context.ConnectionId), msg);
 }
Esempio n. 3
0
 public override async Task OnDisconnectedAsync(Exception exception)
 {
     UserManagement.Remove(Context.ConnectionId);
     await base.OnDisconnectedAsync(exception);
 }