示例#1
0
        public GasUserHub Connect(GasUserHub user)
        {
            try
            {
                user.SessionId = Context.ConnectionId;
                _connectedUsers.RemoveAll(x => x.UserName == user.UserName);
                _connectedUsers.Add(user);
                var usersConnected = new List <GasUserHub>();
                usersConnected = _connectedUsers;
                switch (user.GasProfile)
                {
                case GasProfile.Subastador:
                    Groups.Add(Context.ConnectionId, GasProfile.Subastador.ToString());
                    break;

                case GasProfile.Comprador:
                    Groups.Add(Context.ConnectionId, GasProfile.Comprador.ToString());
                    break;

                case GasProfile.Vendedor:
                    Groups.Add(Context.ConnectionId, GasProfile.Vendedor.ToString());
                    break;
                }
                Clients.All.onNotifyConectedUser(usersConnected);
            }
            catch (Exception e)
            {
            }
            finally
            {
            }

            return(user);
        }
示例#2
0
        Task IHub.OnDisconnected(bool stopCalled)
        {
            GasUserHub user = null;

            try
            {
                user = _connectedUsers.FirstOrDefault(x => x.SessionId.Equals(Context.ConnectionId));

                _connectedUsers.Remove(user);
                return(base.OnDisconnected(stopCalled));
            }
            catch (Exception e)
            {
                return(null);
            }
            finally
            {
                //this.Logchat.SaveLogOutUser(user);
            }
        }