private static void HandleRpcEvent(RpcTestEvent message, PingPongClient client) { lock (pingPongLock) { eventResult = message.id + ""; Monitor.Pulse(pingPongLock); } }
public void PingPong() { var server = new PingPongServer(); var client = new PingPongClient(new Client(server.LocalEndPoint)); var aEvent = new RpcTestEvent(); aEvent.id = 922; var message = new RpcTestRequest(); message.id = 316; client.OutgoingService.SendRequest(message, typeof(RpcTestResponse), delegate(ProtoBuf.IExtensible response) { var responseMessage = (RpcTestResponse)response; lock (pingPongLock) { clientResult = responseMessage.id + ""; Monitor.Pulse(pingPongLock); } }, delegate(ProtoBuf.IExtensible fail) { lock (pingPongLock) { clientResult = "wrong!"; if (fail is RpcTestException) { } ; Monitor.Pulse(pingPongLock); } }); lock (pingPongLock) { while (server.serverSession == null) { Monitor.Wait(pingPongLock); } } server.serverSession.OutgoingService.PushMessage(aEvent); lock (pingPongLock) { while (serverResult == null || clientResult == null || eventResult == null) { Monitor.Wait(pingPongLock); } } Assert.AreEqual(clientResult, "710"); Assert.AreEqual(serverResult, "316"); Assert.AreEqual(eventResult, "922"); client.Session.ShutDown(); server.serverSession.Session.ShutDown(); server.Clear(); }