예제 #1
0
 public bool RemoveFromActiveChat(ChatUserDetails item)
 {
     try
     {
         context.ChatUserDetails.Remove(item);
         context.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
         Log.Logger.Error(ex);
         return(false);
     }
 }
예제 #2
0
        /// <summary>
        /// Override Function which responsible to deal with an event of user disconnecting the Hub.
        /// </summary>
        /// <param name="stopCalled">Bool para indicate if the disconnecting is valid or not</param>
        /// <returns>Task of OnDisconnected </returns>
        public override Task OnDisconnected(bool stopCalled)
        {
            if (stopCalled)
            {
                ChatUserDetails item = ConnectedUsers.FirstOrDefault(x => x.ConnectionId.Equals(Context.ConnectionId));
                if (item != null)
                {
                    ConnectedUsers.Remove(item);
                    Clients.Group(item.CatId.ToString()).onUserDisconnected(item.ConnectionId, item.UserName);
                }
            }
            else
            {
                // This server hasn't heard from the client in the last ~35 seconds.
                // If SignalR is behind a load balancer with scaleout configured,
                // the client may still be connected to another SignalR server.
            }

            return(base.OnDisconnected(stopCalled));
        }
예제 #3
0
        public bool AppendToChat(string connectionId, string username, string userid)
        {
            try
            {
                var userDetail = new ChatUserDetails
                {
                    ConnectionId = connectionId,
                    UserId       = userid
                };

                context.ChatUserDetails.Add(userDetail);
                context.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                Log.Logger.Error(ex);
                return(false);
            }
        }
예제 #4
0
 public bool RemoveFromActiveChat(ChatUserDetails item)
 {
     return(repository.RemoveFromActiveChat(item));
 }