public void OnTimer2EchoCallback(ErrorCode err, RpcReadStream response) { if (err == ErrorCode.ERR_OK) { string v; response.Read(out v); //Logging.dassert(v == "hi, this is timer2 echo", //"incorrect responsed value"); } var c = ++_count_timer2; if (c % 10000 == 0) { var gap = DateTime.Now - _last_ts; _last_ts = DateTime.Now; Console.WriteLine("Timer2: Cost {0} ms for {1} tasks", gap.TotalMilliseconds, _count_timer2); _count_timer1 = 0; //cancel_all_pending_tasks(); } string cs = new string('v', 1024 * 1024); RpcWriteStream s = new RpcWriteStream(EchoClientApp.RPC_ECHO, 1000, 0); s.Write(cs); s.Flush(); RpcCallAsync(_server, s, this, this.OnTimer2EchoCallback, 0); }
public void OnEcho(RpcReadStream request, RpcWriteStream response) { string v; request.Read(out v); response.Write(v); response.Flush(); Reply(response); }
// all service handlers to be implemented further // RPC_ECHO_ECHO_PING private void OnpingInternal(RpcReadStream request, RpcWriteStream response) { string val; try { request.Read(out val); } catch (Exception) { // TODO: error handling return; } Onping(val, new RpcReplier <string>(response, (s, r) => { s.Write(r); s.Flush(); })); }