public void VotingServerTest() { TcpRpcServer server = new TcpRpcServer(new VotingRpcServer()); server.Start(); CertificateStorage storage = new CertificateStorage(); TcpRpcClient client = new TcpRpcClient(); client.Connect(new IPEndPoint(IPAddress.Loopback, 4242)); Assert.IsTrue(client.Connected); VotingRpcProxy proxy = new VotingRpcProxy(client); proxy.Start(); var ids = proxy.FetchVotingIds(); proxy.Stop(); client.Disconnect(); Assert.IsFalse(client.Connected); server.Stop(); }
private void ConnectAsync() { try { this.client.Connect(this.serverEndPoint); this.proxy = new VotingRpcProxy(this.client); this.proxy.Start(); this.exception = null; } catch (Exception exception) { this.exception = exception; } Connecting = false; }
private void ConnectPiVote() { if (this.valid) { try { this.client = new TcpRpcClient(); this.client.Connect(new IPEndPoint(IPAddress.Loopback, 4242)); this.proxy = new VotingRpcProxy(client); } catch (Exception exception) { this.error = exception.Message; this.message = "Pi-Vote server connection failed."; this.valid = false; } } }
/// <summary> /// Connect to the server. /// </summary> /// <param name="serverEndPoint">IP address and port of the server.</param> /// <param name="serverEndPoint">Proxy IP address and port.</param> public void Connect(IPEndPoint serverEndPoint, IPEndPoint proxyEndPoint) { this.client.Connect(serverEndPoint, proxyEndPoint); this.proxy = new VotingRpcProxy(this.client); this.proxy.Start(); }
private bool ConnectToServer() { table.AddHeaderRow(2, "Pi-Vote Server"); string fileName = Path.Combine(Request.PhysicalApplicationPath, "server.pi-cert"); if (File.Exists(fileName)) { this.serverCertificate = Serializable.Load<ServerCertificate>(fileName); } else { table.AddRow("Connection:", "N/A"); table.AddRow(string.Empty, "Server certifcate not found."); table.AddSpaceRow(2, 32); return false; } try { this.client = new TcpRpcClient(); this.client.Connect(new IPEndPoint(IPAddress.Loopback, 4242)); this.proxy = new VotingRpcProxy(client); } catch { table.AddRow("Connection:", "Failed"); table.AddRow(string.Empty, "Pi-Vote server connection failed."); table.AddSpaceRow(2, 32); return false; } try { var result = proxy.FetchCertificateStorage(); this.certificateStorage = new CertificateStorage(); this.certificateStorage.TryLoadRoot(Request.PhysicalApplicationPath); this.certificateStorage.Add(result.First); } catch { table.AddRow("Connection:", "Failed"); table.AddRow(string.Empty, "Cannot download certificate storage."); table.AddSpaceRow(2, 32); return false; } table.AddRow("Connection:", "Ok"); table.AddSpaceRow(2, 32); return true; }