/// <summary> /// Initializes the client. /// </summary> /// <param name="client">The ETP client.</param> /// <returns>The ETP client.</returns> protected EtpClient InitClient(EtpClient client) { // Register client handlers client.Register <IChannelStreamingConsumer, ChannelStreamingConsumerHandler>(); client.Register <IDiscoveryCustomer, DiscoveryCustomerHandler>(); client.Register <IStoreCustomer, StoreCustomerHandler>(); return(client); }
private void RegisterProtocolHandlers(EtpClient client) { if (Requesting(Protocols.ChannelStreaming, "producer")) { client.Register <IChannelStreamingConsumer, ChannelStreamingConsumerHandler>(); RegisterEventHandlers(client.Handler <IChannelStreamingConsumer>()); } if (Requesting(Protocols.ChannelStreaming, "consumer")) { client.Register <IChannelStreamingProducer, ChannelStreamingProducerHandler>(); RegisterEventHandlers(client.Handler <IChannelStreamingProducer>()); } if (Requesting(Protocols.ChannelDataFrame, "producer")) { client.Register <IChannelDataFrameConsumer, ChannelDataFrameConsumerHandler>(); RegisterEventHandlers(client.Handler <IChannelDataFrameConsumer>()); } if (Requesting(Protocols.ChannelDataFrame, "consumer")) { client.Register <IChannelDataFrameProducer, ChannelDataFrameProducerHandler>(); RegisterEventHandlers(client.Handler <IChannelDataFrameProducer>()); } if (Requesting(Protocols.Discovery, "store")) { client.Register <IDiscoveryCustomer, DiscoveryCustomerHandler>(); RegisterEventHandlers(client.Handler <IDiscoveryCustomer>(), x => x.OnGetResourcesResponse += OnGetResourcesResponse); } if (Requesting(Protocols.Store, "store")) { client.Register <IStoreCustomer, StoreCustomerHandler>(); RegisterEventHandlers(client.Handler <IStoreCustomer>(), x => x.OnObject += OnObject); } if (Requesting(Protocols.StoreNotification, "store")) { client.Register <IStoreNotificationCustomer, StoreNotificationCustomerHandler>(); RegisterEventHandlers(client.Handler <IStoreNotificationCustomer>()); } if (Requesting(Protocols.GrowingObject, "store")) { client.Register <IGrowingObjectCustomer, GrowingObjectCustomerHandler>(); RegisterEventHandlers(client.Handler <IGrowingObjectCustomer>(), x => x.OnObjectFragment += OnObjectFragment); } if (Requesting(Protocols.DataArray, "store")) { client.Register <IDataArrayCustomer, DataArrayCustomerHandler>(); RegisterEventHandlers(client.Handler <IDataArrayCustomer>()); } if (Requesting(Protocols.WitsmlSoap, "store")) { //client.Register<IWitsmlSoapCustomer, WitsmlSoapCustomerHandler>(); //RegisterEventHandlers(client.Handler<IWitsmlSoapCustomer>()); } }
private void Connect2Server_Button_Click(object sender, RoutedEventArgs e) { Client = new EtpClient(ServerUri_TextBox.Text, AppName_TextBox.Text, Version_TextBox.Text); Client.Register <IDiscoveryCustomer, DiscoveryCustomerHandler>(); Client.Output = LogClientOutput; Client.Open(); //System.Windows.MessageBox.Show(Proto_ListBox.SelectedIndex.ToString()); //foreach (var item in Proto_ListBox.SelectedItems) //{ // System.Windows.MessageBox.Show(item.ToString()); //} }
private async Task <bool> CanConnect(Connection connection, IDictionary <string, string> headers) { try { var applicationName = GetType().Assembly.FullName; var applicationVersion = GetType().GetAssemblyVersion(); connection.UpdateEtpSettings(headers); connection.SetServerCertificateValidation(); using (var client = new EtpClient(connection.Uri, applicationName, applicationVersion, headers)) { client.Register <IChannelStreamingConsumer, ChannelStreamingConsumerHandler>(); client.Register <IDiscoveryCustomer, DiscoveryCustomerHandler>(); client.Register <IStoreCustomer, StoreCustomerHandler>(); var count = 0; client.Open(); while (string.IsNullOrWhiteSpace(client.SessionId) && count < 10) { await Task.Delay(1000); count++; } var result = !string.IsNullOrWhiteSpace(client.SessionId); _log.DebugFormat("ETP connection test {0}", result ? "passed" : "failed"); return(result); } } catch (Exception ex) { _log.Error("ETP connection test failed", ex); return(false); } }
private void Button_Click(object sender, RoutedEventArgs e) { Client = new EtpClient(ServerUrl, "MyPDS", "1.0.0.0"); Client.Register <IDiscoveryCustomer, DiscoveryCustomerHandler>(); RegisterEventHandlers(Client.Handler <IDiscoveryCustomer>(), x => x.OnGetResourcesResponse += OnGetResourcesResponse); Client.Output = LogClientOutput; Client.Open(); //System.Windows.MessageBox.Show(Client.IsOpen.ToString()); }