public void SendData() { using var sc = new ServerClientPair <RpcServer, RpcClient>(); using var evt = new ManualResetEvent(false); EndPoint ep = null; sc.server.ClientConnected += (sender, e) => { Log($"Server connected to {e.Value}"); ep = e.Value; evt.Set(); }; sc.server.ReceivedData += (sender, e) => { Log($"Server read from {e.V1} {e.V2.FuncName}, {e.V2.Parameters.Length}"); Assert.Equal("Test", e.V2.FuncName); Assert.Equal(3, e.V2.Parameters.Length); evt.Set(); }; sc.client.ReceivedData += (sender, e) => { Log($"Client read from {e.V1} {e.V2.FuncName}, {e.V2.Parameters.Length}"); Assert.Equal("Test1", e.V2.FuncName); Assert.Equal(2, e.V2.Parameters.Length); evt.Set(); }; sc.Start(); evt.WaitOne(); evt.Reset(); sc.client.Send("Test", new object[] { 1, 2, 3 }); evt.WaitOne(); evt.Reset(); sc.server.Send(ep, "Test1", new object[] { 1, 2 }); evt.WaitOne(); evt.Reset(); }
public void Connect() { using var sc = new ServerClientPair <RpcServer, RpcClient>(); sc.Start(); }