private void m_btnRun_Click(object sender, EventArgs e) { try { //using (JokeHelper.MakeApp()) { var cl = new JokeContractClient(DEFAULT_TEST_SERVER_SYNC_NODE); cl.Headers.Add(new AuthenticationHeader(DEFAULT_TEST_CREDENTIALS)); var result = cl.Echo("Gello A!"); m_txtLog.AppendText(result); m_txtLog.AppendText(Environment.NewLine); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void m_btnCallAsync_Click(object sender, EventArgs e) { try { using (var cl = new JokeContractClient(DEFAULT_TEST_SERVER_ASYNC_NODE)) { cl.Headers.Add(new AuthenticationHeader(DEFAULT_TEST_CREDENTIALS)); var result = cl.Echo("Gello A!"); m_txtLog.AppendText(result); m_txtLog.AppendText(Environment.NewLine); } var glue = App.Glue as NFX.Glue.Implementation.GlueService; var binding = glue.Bindings["async"]; var active = binding.ClientTransports.ToList(); foreach (var ct in active) ct.Dispose(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void GlueConfiguredByCodeAndMakeCall_Sync() { //This is an example of how to use Glue without pre-configured app container var app = new TestApplication(){ Active = true }; var glue = new NFX.Glue.Implementation.GlueService(app); glue.Start(); try { using(var binding = new SyncBinding(glue, "sync")) { binding.Start(); var cl = new JokeContractClient(glue, TestServerSyncNode); cl.Headers.Add( new AuthenticationHeader( TestCredentials ) ); var result = cl.Echo("Gello A!"); Assert.IsTrue(result.StartsWith("Server echoed Gello A!")); } } finally { glue.WaitForCompleteStop(); } }
private string LongRunningMethod(string message) { int errQty = 0; for (int i = 0; i < 10000000; i++) { try { using (var cl = new JokeContractClient(DEFAULT_TEST_SERVER_ASYNC_NODE)) { cl.Headers.Add(new AuthenticationHeader(DEFAULT_TEST_CREDENTIALS)); var result = cl.Echo("Gello A!"); //LogLine(result); if (i % 10 == 0) LogTotal(i, errQty); } // close all transports var glue = App.Glue as NFX.Glue.Implementation.GlueService; var binding = glue.Bindings["async"]; var active = binding.ClientTransports.ToList(); foreach (var ct in active) ct.Dispose(); } catch (Exception ex) { errQty++; LogLine(ex.Message); //MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } return message; }
public void Sync_JokeContract_Expected_Security_Exception() { using (JokeHelper.MakeApp()) { var cl = new JokeContractClient(TestServerSyncNode); var result = cl.Echo("Blah");//throws sec exception } }
public void Sync_JokeContract_Echo_ByCode() { using( JokeHelper.MakeApp()) { var cl = new JokeContractClient(TestServerSyncNode); cl.Headers.Add( new AuthenticationHeader( TestCredentials ) ); var result = cl.Echo("Gello A!"); Assert.IsTrue(result.StartsWith("Server echoed Gello A!")); } }
private void btnSimple_Click(object sender, EventArgs e) { warmup(); var unsecure = chkUnsecureEcho.Checked; Text = "Working..."; tbNote.Text = "Started..."; var w = Stopwatch.StartNew(); var client = new JokeContractClient(cbo.Text); client.DispatchTimeoutMs = 5 * 1000; client.TimeoutMs = 40 * 1000; if (!unsecure && chkImpersonate.Checked) client.Headers.Add( new AuthenticationHeader( new IDPasswordCredentials(tbID.Text, tbPwd.Text)) ); var totalCalls = tbCallsPerReactor.Text.AsInt(); var totalErrors = 0; System.Threading.Tasks.Parallel.For(0, totalCalls, (i) => { try { if (unsecure) client.UnsecureEcho("Call number {0} ".Args(i)); else client.Echo("Call number {0} ".Args(i)); } catch (Exception) { Interlocked.Increment(ref totalErrors); } }); var allFinished = w.ElapsedMilliseconds; Text = "Placed {0:n2} calls in {1:n2} ms total time {2:n2} ms @ {3:n2} calls/sec; totalErrors={4:n2} " .Args ( totalCalls, allFinished, allFinished, totalCalls / (allFinished/1000d), totalErrors ); }
private void button2_Click(object sender, EventArgs ea) { var CNT = edRepeat.Text.AsInt(); var client = new JokeContractClient(cbo.Text); client.Headers.Add( new AuthenticationHeader( new IDPasswordCredentials(tbID.Text, tbPwd.Text)) ); // client.ReserveTransport = true; var w = Stopwatch.StartNew(); try { if (chkUnsecureEcho.Checked) { for(int i=0; i<CNT; i++) client.UnsecureEcho("Hello!"); } else { for(int i=0; i<CNT; i++) client.Echo("Hello!"); } w.Stop(); Text = "Echoed "+CNT.ToString()+" in " + w.ElapsedMilliseconds + " ms"; } catch (Exception e) { Text = e.ToMessageWithType(); } client.Dispose(); }
private void button1_Click(object sender, EventArgs ea) { ECHO_COUNT++; var client = new JokeContractClient(cbo.Text); client.Headers.Add( new AuthenticationHeader( new IDPasswordCredentials(tbID.Text, tbPwd.Text)) ); try { var echoed = chkUnsecureEcho.Checked ? client.UnsecureEcho("Hello!") : client.Echo("Hello!"); Text = echoed + " " + ECHO_COUNT.ToString() + " times"; } catch (Exception e) { Text = e.ToMessageWithType(); } client.Dispose(); }