Exemple #1
0
        /// <summary>
        /// Logs a status message to hub client and any provided log status message delegate.
        /// </summary>
        /// <param name="message">Message content to log.</param>
        /// <param name="type">Type of message to log.</param>
        /// <param name="logToClient">Determines if message should be logged to hub client.</param>
        /// <remarks>
        /// When <paramref name="logToClient"/> is <c>true</c>, function will
        /// call "sendInfoMessage" Javascript hub client function if defined.
        /// </remarks>
        protected void LogStatusMessage(string message, UpdateType type = UpdateType.Information, bool logToClient = true)
        {
            // Send status message to hub client
            if (logToClient)
            {
                ClientScript?.sendInfoMessage(message, type == UpdateType.Information ? 2000 : -1);
            }

            // Send status message to program host
            LogStatusMessageFunction?.Invoke(message, type);
        }
Exemple #2
0
        /// <summary>
        /// Logs a status message to hub client and any provided log status message delegate.
        /// </summary>
        /// <param name="message">Message content to log.</param>
        /// <param name="type">Type of message to log.</param>
        /// <param name="logToClient">Determines if message should be logged to hub client.</param>
        /// <remarks>
        /// When <paramref name="logToClient"/> is <c>true</c>, function will
        /// call "sendInfoMessage" Javascript hub client function if defined.
        /// </remarks>
        protected void LogStatusMessage(string message, UpdateType type = UpdateType.Information, bool logToClient = true)
        {
            try
            {
                // Send status message to hub client
                if (logToClient)
                {
                    ClientScript?.sendInfoMessage(message, type == UpdateType.Information ? 2000 : -1);
                }
            }
            catch (NullReferenceException)
            {
                // Attempting to access this property from self-created hub instance, i.e., a manually created
                // instance instead of one created by SignalR, will cause a null-reference exception.
            }

            // Send status message to program host
            LogStatusMessageFunction?.Invoke(message, type);
        }