Beispiel #1
0
 public override Task OnConnected()
 {
     if (Context.User.Identity.GetUserId() == null)
     {
         var userId = _accessTokenService.GetUserId(Context.QueryString["accessToken"]);
         if (userId != null)
         {
             if (_driverService.GetAll().Where(x => x.UserId == userId).FirstOrDefault() != null)
             {
                 _driverService.AddOnlineDriver(userId, Context.ConnectionId);
             }
             else if (_clientService.GetAll().Where(x => x.UserId == userId) != null)
             {
                 _clientService.AddOnlineClient(userId, Context.ConnectionId);
             }
         }
         else
         {
             return(base.OnDisconnected(true));
         }
     }
     else
     {
         _dispatcherService.AddOnlineDispatcher(Context.User.Identity.GetUserId(), Context.ConnectionId);
     }
     Clients.All.hey();
     return(base.OnConnected());
 }