Exemple #1
0
 public PodeClientSignal(PodeWebSocket webSocket, string message, PodeListener listener)
 {
     WebSocket = webSocket;
     Message   = message;
     Timestamp = DateTime.UtcNow;
     Listener  = listener;
 }
Exemple #2
0
 public PodeServerSignal(string value, string path, string clientId, PodeListener listener)
 {
     Value     = value;
     Path      = path;
     ClientId  = clientId;
     Timestamp = DateTime.UtcNow;
     Listener  = listener;
 }
Exemple #3
0
        public static void HandleAggregateException(AggregateException aex, PodeListener listener = default(PodeListener), PodeLoggingLevel level = PodeLoggingLevel.Error)
        {
            aex.Handle((ex) =>
            {
                if (ex is IOException || ex is OperationCanceledException)
                {
                    return(true);
                }

                PodeHelpers.WriteException(ex, listener, level);
                return(false);
            });
        }
Exemple #4
0
        public static void WriteException(Exception ex, PodeListener listener = default(PodeListener))
        {
            if (ex == default(Exception))
            {
                return;
            }

            if (listener != default(PodeListener) && !listener.ErrorLoggingEnabled)
            {
                return;
            }

            Console.WriteLine(ex.Message);
            Console.WriteLine(ex.StackTrace);
        }
Exemple #5
0
        public static void WriteException(Exception ex, PodeListener listener = default(PodeListener), PodeLoggingLevel level = PodeLoggingLevel.Error)
        {
            if (ex == default(Exception))
            {
                return;
            }

            // return if logging disabled, or if level isn't being logged
            if (listener != default(PodeListener) && (!listener.ErrorLoggingEnabled || !listener.ErrorLoggingLevels.Contains(level.ToString(), StringComparer.InvariantCultureIgnoreCase)))
            {
                return;
            }

            // write the exception to terminal
            Console.WriteLine($"[{level}] {ex.GetType().Name}: {ex.Message}");
            Console.WriteLine(ex.StackTrace);
        }
Exemple #6
0
        public static void WriteErrorMessage(string message, PodeListener listener = default(PodeListener), PodeLoggingLevel level = PodeLoggingLevel.Error, PodeContext context = default(PodeContext))
        {
            // do nothing if no message
            if (string.IsNullOrWhiteSpace(message))
            {
                return;
            }

            // return if logging disabled, or if level isn't being logged
            if (listener != default(PodeListener) && (!listener.ErrorLoggingEnabled || !listener.ErrorLoggingLevels.Contains(level.ToString(), StringComparer.InvariantCultureIgnoreCase)))
            {
                return;
            }

            if (context == default(PodeContext))
            {
                Console.WriteLine($"[{level}]: {message}");
            }
            else
            {
                Console.WriteLine($"[{level}]: [ContextId: {context.ID}] {message}");
            }
        }