/// <summary> /// Start the module. /// </summary> public override void Start() { base.Start(); var first = m_MqDistributions.Last(); var last = m_MqDistributions.First(); Task.Factory.StartNew(() => { while (Defaults.IsIsolatedJob) { System.Threading.Thread.Sleep(1); for (int i = 0; i < m_MqDistributions.Count; i++) { foreach (var msg in m_MqDistributions[i].ReadMessages()) { try { m_TransferMessageCallbacks[i]?.Call(msg); } catch (Exception ex) { LoggerPool.Log(Name, new LogContentEntity() { Level = "Error", Message = ex.Message + ex.StackTrace }); } } } }//while }); }
public void Connect() { try { ConnectAsync(); } catch (AggregateException ex) { foreach (var exItem in ex.InnerExceptions) { LoggerPool.Log(Name, new LogContentEntity() { Level = "Error", Message = exItem.Message + exItem.StackTrace }); } } catch (Exception ex) { LoggerPool.Log(Name, new LogContentEntity() { Level = "Error", Message = ex.Message + ex.StackTrace }); } }
public virtual void Connection_ConnectionSlow() { string msg = "You have been connectionslow."; LoggerPool.Log(Name, new LogContentEntity() { Level = "Warn", Message = msg }); }
public virtual void Connection_Reconnected() { string msg = "You have been Reconnected."; LoggerPool.Log(Name, new LogContentEntity() { Level = "Info", Message = msg }); }
public override void Start() { foreach (var signalRClient in signalRClients) { signalRClient.Connect(); LoggerPool.Log("", new LogPool.LogContentEntity() { Level = "Info", Message = signalRClient.Name + " call Connect();" }); } }
public override void Initialize() { base.Initialize(); try { signalRClients = IocManager.Resolve <IEnumerable <ISignalRClient> >(); } catch (System.Exception ex) { LoggerPool.Log("", new LogPool.LogContentEntity() { Level = "Error", Message = ex.Message + ex.StackTrace }); } }
public override void RegisterServerMethod() { try { HubProxy.On <string>("broadcastMessage", (message) => { LoggerPool.Log(Name, new LogPool.LogContentEntity() { Message = message }); }); } catch (AggregateException ex) { foreach (var exItem in ex.InnerExceptions) { var msg = exItem.Message + exItem.GetType().ToString() + exItem.StackTrace; LoggerPool.Log(Name, new LogContentEntity() { Level = "Error", Message = msg }); } } catch (System.Exception ex) { var msg = string.Empty; LoggerPool.Log(Name, new LogContentEntity() { Level = "Error", Message = ex.Message + ex.StackTrace }); } }
private async void ConnectAsync() { connection = new HubConnection(SignalRClientConfig.ServerUrl); switch (AuthenticationType) { case AuthenticationType.None: break; case AuthenticationType.Cookie: Cookie returnedCookie; var authResult = SignalRClientConfig.CookieAuthenticate.AuthenticateUser(out returnedCookie); if (authResult) { connection.CookieContainer = new CookieContainer(); connection.CookieContainer.Add(returnedCookie); } else { Console.WriteLine("Login failed"); } break; case AuthenticationType.Windows: connection.Credentials = CredentialCache.DefaultCredentials; break; case AuthenticationType.Token: connection.Headers.Add(SignalRClientConfig.TokenData.Name, SignalRClientConfig.TokenData.Token); break; case AuthenticationType.Certificate: connection.AddClientCertificate(X509Certificate.CreateFromCertFile(SignalRClientConfig.CertificateName)); break; default: break; } connection.Closed += Connection_Closed; connection.Reconnected += Connection_Reconnected; connection.ConnectionSlow += Connection_ConnectionSlow; HubProxy = connection.CreateHubProxy(SignalRClientConfig.HubName); RegisterServerMethod(); try { await connection.Start().ContinueWith((t) => { if (t.IsFaulted) { foreach (var exItem in t.Exception.InnerExceptions) { var msg = exItem.Message + exItem.GetType().ToString() + exItem.StackTrace; LoggerPool.Log(Name, new LogContentEntity() { Level = "Error", Message = msg }); } } else { LoggerPool.Log(SignalRClientConfig.HubName, new LogContentEntity() { Level = "Info", Message = "Connect success" }); OnConnected(); } }); } catch (HttpRequestException ex) { var msg = "Unable to connect to server: Start server before connecting clients."; LoggerPool.Log(SignalRClientConfig.HubName, new LogContentEntity() { Level = "Error", Message = msg + ex.Message + ex.StackTrace }); } }