Beispiel #1
0
        /// <summary>
        /// Logs a status message.
        /// </summary>
        /// <param name="message">Message to log.</param>
        /// <param name="type">Type of message to log.</param>
        public static void LogStatusMessage(string message, UpdateType type = UpdateType.Information)
        {
            ThreadPool.QueueUserWorkItem(state =>
            {
                string connectionID = state as string;

                if (!string.IsNullOrEmpty(connectionID))
                {
                    if (type == UpdateType.Information)
                    {
                        HubClients.Client(connectionID).sendInfoMessage(message, 3000);
                    }
                    else
                    {
                        HubClients.Client(connectionID).sendErrorMessage(message, type == UpdateType.Alarm ? -1 : 3000);
                    }
                }
#if DEBUG
                else
                {
                    Thread.Sleep(1500);
                    if (type == UpdateType.Information)
                    {
                        HubClients.All.sendInfoMessage(message, 3000);
                    }
                    else
                    {
                        HubClients.All.sendErrorMessage(message, type == UpdateType.Alarm ? -1 : 3000);
                    }
                }
#endif
            }, DataHub.CurrentConnectionID);
        }
Beispiel #2
0
 public ChatHub(
     IHostApplicationLifetime lifetime,
     HubClients clients)
 {
     _lifetime = lifetime;
     _clients  = clients;
 }
Beispiel #3
0
        /// <summary>
        /// Maps the related information together, like base controllers
        /// </summary>
        public void MapRelatedInfo()
        {
            foreach (var client in HttpClients)
            {
                if (!string.IsNullOrEmpty(client.BaseClass))
                {
                    client.BaseController = HttpClients.SingleOrDefault(x => x.Name == client.BaseClass);
                }
            }

            foreach (var client in HubClients)
            {
                if (!string.IsNullOrEmpty(client.BaseClass))
                {
                    client.BaseController = HubClients.SingleOrDefault(x => x.Name == client.BaseClass);
                }
            }
        }
Beispiel #4
0
        /// <summary>
        /// Logs an exception.
        /// </summary>
        /// <param name="ex">Exception to log.</param>
        public static void LogException(Exception ex)
        {
            ThreadPool.QueueUserWorkItem(state =>
            {
                string connectionID = state as string;

                if (!string.IsNullOrEmpty(connectionID))
                {
                    HubClients.Client(connectionID).sendErrorMessage(ex.Message, -1);
                }
#if DEBUG
                else
                {
                    Thread.Sleep(1500);
                    HubClients.All.sendErrorMessage(ex.Message, -1);
                }
#endif
            }, DataHub.CurrentConnectionID);
        }