Exemplo n.º 1
0
 public override Task OnConnected()
 {
     using (UnitOfWork uow = new UnitOfWork())
     {
         var user = uow.FindObject <XpoApplicationUser>(CriteriaOperator.Parse("UserName==?", Context.User.Identity.Name));
         if (user != null)
         {
             var con = new UserConnections
             {
                 ConnectionId = Context.ConnectionId,
                 UserAgent    = Context.Request.Headers["User-Agent"],
                 Connected    = true,
                 UserId       = user.Id
             };
             connectionList.Add(con);
             var userInList = listAllConnections.Find(u => u.UserId == user.Id);
             if (userInList == null)
             {
                 listAllConnections.Add(new ConnectionList
                 {
                     UserId   = user.Id,
                     Username = user.UserName
                 });
             }
             Clients.All.BroadcastConnections(listAllConnections);
         }
         return(base.OnConnected());
     }
 }
Exemplo n.º 2
0
 public override Task OnConnected()
 {
     using (UnitOfWork uow = new UnitOfWork())
     {
         var user = uow.FindObject <XpoApplicationUser>(CriteriaOperator.Parse("UserName==?", Context.User.Identity.Name));
         if (user != null)
         {
             var con = new UserConnections
             {
                 ConnectionId = Context.ConnectionId,
                 UserAgent    = Context.Request.Headers["User-Agent"],
                 Connected    = true,
                 UserId       = user.Id
             };
             ConnectionList.Add(con);
         }
         return(base.OnConnected());
     }
 }