Ejemplo n.º 1
0
        /// <summary>
        /// SignalRChannel constructor
        /// </summary>
        /// <param name="url">Channel url</param>
        /// <param name="bridge">Method bridge</param>
        /// <param name="logger">event listener</param>
        public SignalRChannel(string url, MethodBridge bridge, ILogger logger = null)
            : base(DefaultDelay)
        {
            Url    = new Uri(url);
            Bridge = bridge;
            Logger = logger ?? new LogEventWriter <SignalRChannel>(x => { });

            base.Advised += x =>
            {
                switch (x)
                {
                case RunnerEventMessage runner:
                    if (runner.Exception == null)
                    {
                        return;
                    }
                    Logger.LogError(runner.Exception, runner.Exception.Message);
                    Advised.Invoke(new SignalRAdviseMessage(runner.Exception));
                    return;

                case LogEventMessage log:
                    Logger.LogMessage(log.LogLevel, log.EventInfo, log.Message, log.Exception);
                    Advised.Invoke(new SignalRAdviseMessage(log.Message, log.Exception));
                    return;

                case SignalRChangedMessage changed:
                    Changed.Invoke(changed);
                    return;
                }
            };

            ConnectionState = SignalRChannelState.Off;
        }
Ejemplo n.º 2
0
 protected SignalRTextChannel(string url, MethodBridge bridge, ILogger logger = null)
     : base(url, bridge, logger)
 {
 }