public void Add(RpcServerContext context) { RpcClass <int, int> c = context.GetArgs <RpcClass <int, int> >(); // Console.WriteLine("Rpc.Test1 {0} {1}", c.Value1, c.Value2); context.Return(c.Value1 + c.Value2); }
public void ListFailedTransactions(RpcServerContext ctx) { if (_coordinator == null) { throw new Exception("Coordinator is Null"); } string transName = ctx.GetArgs <string>(); if (transName != _coordinator.TransName) { throw new Exception("TransName not Matched"); } List <TccTransactionData> dataList = (List <TccTransactionData>)_coordinator.GetFailedTransactions(); RpcList <TccTransactionData> rpcList = null; if (dataList != null && dataList.Count > 0) { rpcList = new RpcList <TccTransactionData>(); foreach (TccTransactionData data in dataList) { rpcList.Value.Add(data); } } ctx.Return <RpcList <TccTransactionData> >(rpcList); }
public void Register(RpcServerContext ctx) { // // 已经连接过的就返回失败 if (ctx.Connection.Contexts["session"] != null) { ctx.ReturnError(RpcErrorCode.ConnectionBroken, null); return; } var args = ctx.GetArgs <DuplexDemoRegisterArgs>(); if (args.UserName == "foo" && args.Passwd == "bar") { // // 注册成功, 建立session对象 var session = new DuplexDemoSession() { Id = Guid.NewGuid().ToString(), LastTime = DateTime.Now, Connection = ctx.Connection, }; ctx.Connection.Contexts["session"] = session; lock (_syncRoot) { _agents.Add(ctx.From, session); } ctx.Return(); } else { ctx.ReturnError(RpcErrorCode.ConnectionFailed, new Exception("UserNotFound")); } }
public void KeepAlive(RpcServerContext ctx) { int seconds = ctx.GetArgs <int>(); DuplexDemoSession session = (DuplexDemoSession)ctx.Connection.Contexts["session"]; session.LastTime = DateTime.Now.AddSeconds(seconds); ctx.Return(0); // 没意义 }
public void AppendSystemLog(RpcServerContext context) { RpcList <SystemLogEvent> evts = context.GetArgs <RpcList <SystemLogEvent> >(); foreach (SystemLogEvent evt in evts.Value) { Console.WriteLine(evt.ToString()); } WaitEvent.Set(); context.Return(); }
public void Register(RpcServerContext ctx) { var token = (RpcDuplexConnectionToken)ctx.Connection.Contexts["Duplex"]; if (token.Registerd) { ctx.Return(RpcErrorCode.ConnectionFailed); return; } else { token.ProcessRegister(ctx); } }
public void KeepAlive(RpcServerContext ctx) { var token = (RpcDuplexConnectionToken)ctx.Connection.Contexts["Duplex"]; if (token != null && token.Registerd) { token.ProcessKeepalive(ctx); } else { ctx.Return(RpcErrorCode.ConnectionFailed); return; } }
public void Return(TResults ret) { InnerContext.Return <TResults>(ret); }
public void TestTimeout(RpcServerContext context) { Thread.Sleep(60000); context.Return(); }
public void Array(RpcServerContext context) { byte[] a = context.GetArgs <byte[]>(); context.Return(a); }
public void Default(RpcServerContext context) { RpcClass <int> a = new RpcClass <int>(); context.Return(a); }
public void Null(RpcServerContext context) { context.Return <RpcClass <int> >(null); }
public void Mirror(RpcServerContext context) { var e = context.GetArgs <RpcClass <int> >(); context.Return(e); }