public ControlClient(ECDsa key, string host) { if (host.StartsWith("https")) { channel = GrpcChannel.ForAddress(host, new() { Credentials = new SslCredentials() }); } else { channel = GrpcChannel.ForAddress(host, new() { Credentials = SslCredentials.Insecure }); } this.key = key; controlServiceClient = new ControlService.ControlServiceClient(channel); }
public Panel() { // HierarchicalDataTemplate InitializeComponent(); // this.vbImage.GetBindingExpression(Viewbox.DataContextProperty). // dbservice = this.Resources["dbservice"] as DomainService1; lnkSave.DataContext = lnkUndo.DataContext = dbservice; dbservice.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(dbservice_PropertyChanged); controlService = new ControlService.ControlServiceClient (new System.ServiceModel.InstanceContext(this), "CustomBinding_IControlService", "net.tcp://"+App.Current.Host.Source.Host+":4502/ControlService"); controlService.RegistAsync(); tmr.Interval = TimeSpan.FromSeconds(60); tmr.Tick += new EventHandler(tmr_Tick); tmr.Start(); }
void tmr_Tick(object sender, EventArgs e) { if (controlService.State == System.ServiceModel.CommunicationState.Opened) { controlService.ToServerSayHelloAsync(); } else { controlService = new ControlService.ControlServiceClient (new System.ServiceModel.InstanceContext(this), "CustomBinding_IControlService", "net.tcp://" + App.Current.Host.Source.Host + ":4502/ControlService"); } //throw new NotImplementedException(); }
private void button1_Click(object sender, RoutedEventArgs e) { chldInputBox input = new chldInputBox("slPanel", "輸入伺服器 IP"); input.Closed += (s, a) => { if (input.DialogResult == true) { slPanel.ControlService.ControlServiceClient client = new ControlService.ControlServiceClient(); client.ImportDevicesCompleted += (ss, aa) => { if (aa.Error != null) { MessageBox.Show("載入失敗"+aa.Error.Message); return; } MessageBox.Show("載入成功,請重新啟動本程式"); }; client.ImportDevicesAsync(input.InputString.Trim(),this.ProjectID); } }; input.Show(); }