public void RPC_SlaveCallsMasterAfterClosed_Exception() { ipcMaster = new RpcBuffer(ipcName, async(msgId, payload) => { }); ipcSlave = new RpcBuffer(ipcName); ipcSlave.RemoteRequest(null); ipcMaster.Dispose(); Assert.ThrowsException <InvalidOperationException>(() => ipcSlave.RemoteRequest(null)); }
public void RPC_Statistics_Reset() { ipcMaster = new RpcBuffer(ipcName); ipcSlave = new RpcBuffer(ipcName, (msgId, payload) => { Assert.IsTrue(payload != null); Assert.IsTrue(payload.Length == 2); // Add the two bytes together return(BitConverter.GetBytes((payload[0] + payload[1]))); }); var result = ipcMaster.RemoteRequest(new byte[] { 123, 10 }); Assert.IsTrue(result.Success); Assert.AreEqual((ulong)1, ipcMaster.Statistics.RequestsSent); Assert.AreEqual((ulong)1, ipcSlave.Statistics.RequestsReceived); Assert.AreEqual((ulong)1, ipcSlave.Statistics.ResponsesSent); Assert.AreEqual((ulong)1, ipcMaster.Statistics.ResponsesReceived); ipcMaster.Statistics.Reset(); var empty = new RpcStatistics(); Assert.AreEqual(empty.RequestsSent, ipcMaster.Statistics.RequestsSent); Assert.AreEqual(empty.ResponsesReceived, ipcMaster.Statistics.ResponsesReceived); Assert.AreEqual(empty.ReadingLastMessageSize, ipcMaster.Statistics.ReadingLastMessageSize); Assert.AreEqual(empty.WritingLastMessageSize, ipcMaster.Statistics.WritingLastMessageSize); }
public void RPC_LoadTest_NestedCalls() { ipcMaster = new RpcBuffer(ipcName, async(msgId, payload) => { // Ask slave to multiply the two bytes return((await ipcMaster.RemoteRequestAsync(new byte[] { 3, 3 }).ConfigureAwait(false)).Data); }); ipcSlave = new RpcBuffer(ipcName, (msgId, payload) => { return(new byte[] { (byte)(payload[0] * payload[1]) }); }); Stopwatch watch = Stopwatch.StartNew(); // Send request to master from slave for (var i = 0; i < 10; i++) { var result = ipcSlave.RemoteRequest(null, 30000); Assert.IsTrue(result.Success); Assert.AreEqual((3 * 3), result.Data[0]); } watch.Stop(); Assert.IsTrue(watch.ElapsedMilliseconds < 1000); }
public void RPC_LoadTest_1k_Large() { ipcMaster = new RpcBuffer(ipcName, async(msgId, payload) => { }, bufferCapacity: 1025 * 512); ipcSlave = new RpcBuffer(ipcName, (msgId, payload) => { return(new byte[] { (byte)(payload[0] * payload[1]) }); }); var buf = new byte[1025 * 512]; buf[0] = 3; buf[1] = 3; Stopwatch watch = Stopwatch.StartNew(); // Send request to slave from master for (var i = 0; i < 1000; i++) { var result = ipcMaster.RemoteRequest(buf, 100); Assert.IsTrue(result.Success); Assert.AreEqual((3 * 3), result.Data[0]); } watch.Stop(); Assert.IsTrue(watch.ElapsedMilliseconds < 2000); }
public async override Task <bool> SendToken(string jsonText) { var rpcGru = new RpcBuffer(appName); //Soup told me not to but its funny var RPCresult = rpcGru.RemoteRequest(Encoding.UTF8.GetBytes(jsonText)); var MinionResponse = Encoding.UTF8.GetString(RPCresult.Data, 0, RPCresult.Data.Length); return(RPCresult.Success); }
public void RPC_MasterCallsSlave_Exception() { ipcMaster = new RpcBuffer(ipcName); ipcSlave = new RpcBuffer(ipcName, async(msgId, payload) => { throw new Exception("test exception"); }); var result = ipcMaster.RemoteRequest(null); Assert.IsFalse(result.Success); }
public void RPC_MasterCallsSlave() { ipcMaster = new RpcBuffer(ipcName); ipcSlave = new RpcBuffer(ipcName, (msgId, payload) => { Assert.IsTrue(payload != null); Assert.IsTrue(payload.Length == 2); // Add the two bytes together return(BitConverter.GetBytes((payload[0] + payload[1]))); }); var result = ipcMaster.RemoteRequest(new byte[] { 123, 10 }); Assert.IsTrue(result.Success); Assert.AreEqual(123 + 10, BitConverter.ToInt32(result.Data, 0)); }
public void RPC_Bidirectional_Nested() { ipcMaster = new RpcBuffer(ipcName, async(msgId, payload) => { // Ask slave to multiply the two bytes return((await ipcMaster.RemoteRequestAsync(new byte[] { 3, 3 }).ConfigureAwait(false)).Data); }); ipcSlave = new RpcBuffer(ipcName, (msgId, payload) => { return(new byte[] { (byte)(payload[0] * payload[1]) }); }); // Send request to master from slave var result = ipcSlave.RemoteRequest(null, 500); Assert.IsTrue(result.Success); Assert.AreEqual((3 * 3), result.Data[0]); }