private static async void ServerEvent(EService service, Barrier barrier) { barrier.SignalAndWait(); bool isRunning = true; while (isRunning) { Log.Debug("start accept"); var eSocket = new ESocket(service); await eSocket.AcceptAsync(); eSocket.Disconnect += ev => { isRunning = false; service.Stop(); }; Echo(eSocket); } }
private static async void ClientEvent(EService service, string hostName, ushort port) { var eSocket = new ESocket(service); await eSocket.ConnectAsync(hostName, port); var stopWatch = new Stopwatch(); stopWatch.Start(); for (int i = 0; i < pingPangCount; ++i) { eSocket.WriteAsync("0123456789".ToByteArray()); var bytes = await eSocket.ReadAsync(); CollectionAssert.AreEqual("9876543210".ToByteArray(), bytes); } stopWatch.Stop(); Log.Debug("time: {0}", stopWatch.ElapsedMilliseconds); await eSocket.DisconnectAsync(); service.Stop(); }