/// <inheritdoc/> /// <remarks> /// Calling this will display a form to the user to enter connection /// information. /// </remarks> public void Participate() { TcpParticipateForm form = new TcpParticipateForm(); form.Submit += delegate { try { TcpClientConnection connection = new TcpClientConnection(form.Address, form.Port); OnJoinSession(new JoinSessionEventArgs(connection)); } catch(ConnectionFailedException) { System.Windows.Forms.MessageBox.Show("Could not connect to " + form.Address + ":" + form.Port); } catch(Exception e) { System.Windows.Forms.MessageBox.Show("An error occurred:\n" + e.ToString(), "Error"); } finally { form.Close(); } }; form.ShowDialog(); }
public void TearDown() { if(server != null) { server.Close(); server = null; } if(client != null) { client.Close(); client = null; } }
public void TestDiscardMultipleConnections() { Assert.Throws(typeof(ConnectionFailedException), delegate { var c = new TcpClientConnection("localhost", port); }); Assert.Throws(typeof(ConnectionFailedException), delegate { var c = new TcpClientConnection("localhost", port); }); Assert.Throws(typeof(ConnectionFailedException), delegate { var c = new TcpClientConnection("localhost", port); }); string serverReceived = ""; server.Received += delegate(object sender, ReceivedEventArgs e) { serverReceived += e.Message.ToString(); }; string text = "Good day to you, sir"; client.Send(text); TestUtil.WaitAreEqual(text, () => serverReceived, 250); server.Close(); }
public void SetUp() { server = new TcpServerConnection(port); client = new TcpClientConnection("localhost", port); }