public bool InitializeSSEClient() { bool connected = false; try { SSEventClient = CreateServerEventsClient("Jars"); SSEventClient.EventStreamRequestFilter = req => { req.AddBearerToken(_AuthResponse.BearerToken); }; //also need to assign the credentials to the underlying ServiceClient. SSEventClient.ServiceClient.BearerToken = _AuthResponse.BearerToken; SSEventClient.Start(); ConnectionStatus = SSEventClient.Status; connected = true; } catch (WebException wex) { ConnectionStatus = $"FAILED - {wex.Message}"; Logger.Fatal(ConnectionStatus, wex); SSEventClient.Stop(); } catch (Exception ex) { Logger.Fatal("InitializeSSClient Exception", ex); SSEventClient.Stop(); } return(connected); }
private void EntityRulesForm_Load(object sender, System.EventArgs e) { if (!this.DesignMode) { if (SSEventClient != null) { if (SSEventClient.Status == "Started") { SSEventClient.SubscribeToChannels(nameof(JarsRule)); } } } SetGridControl(gridControlEntityRules); OnRefreshDataAsync(); }
private void RibbonFormBase_FormClosed(object sender, FormClosedEventArgs e) { if (SSEventClient == null) { return; } if (SSEventClient.Status == "Started") { // AppGlobals.SSEventClient.UnsubscribeFromChannels(Name); SSEventClient.OnCommand -= new Action <ServerEventMessage>(OnCommandEvent); SSEventClient.OnReconnect -= new Action(OnReconnect()); SSEventClient.OnUpdate -= new Action <ServerEventUpdate>(OnUpdateEvent); SSEventClient.OnException -= new Action <Exception>(OnExceptionEvent); SSEventClient.OnMessage -= new Action <ServerEventMessage>(OnMessageEvent); SSEventClient.OnCommand -= new Action <ServerEventMessage>(OnCommandEvent); SSEventClient.UnsubscribeFromChannels(Name); } }
private void RibbonFormBase_Load(object sender, EventArgs e) { if (!this.DesignMode) { if (SSEventClient != null) { if (SSEventClient.Status == "Started") { SSEventClient.SubscribeToChannels(Name); SSEventClient.OnConnect = (subscription) => AppendMetaData(subscription.Meta); SSEventClient.OnCommand += new Action <ServerEventMessage>(OnCommandEvent); SSEventClient.OnReconnect += new Action(OnReconnect()); SSEventClient.OnUpdate += new Action <ServerEventUpdate>(OnUpdateEvent); SSEventClient.OnException += new Action <Exception>(OnExceptionEvent); SSEventClient.OnMessage += new Action <ServerEventMessage>(OnMessageEvent); SSEventClient.OnCommand += new Action <ServerEventMessage>(OnCommandEvent); } } } }