/// <summary>测试主函数</summary> public async static void Main() { var svr = new ApiServer(3344); svr.Add("http://*:888/"); svr.Log = XTrace.Log; svr.Register <HelloController>(); svr.Encoder = new JsonEncoder(); //svr.Encoder = new ProtocolBuffer(); svr.Start(); var client = new ApiClient("udp://127.0.0.1:3344"); client.Log = XTrace.Log; client.Encoder = new JsonEncoder(); //client.Encoder = new ProtocolBuffer(); //client.Compress = new SevenZip(); client.Open(); client.Login("admin", "password"); var msg = "NewLifeX"; var rs = await client.Invoke <String>("Hello/SayHello", new { msg }); Console.WriteLine(rs); Console.ReadKey(); client.Dispose(); svr.Dispose(); }
private static void TestServer() { var svr = new ApiServer(3344); svr.Add("http://*:888/"); svr.Log = XTrace.Log; svr.EncoderLog = XTrace.Log; //svr.Encoder = new JsonEncoder(); //GlobalFilters.Add(new FFAttribute { Name = "全局" }); //GlobalFilters.Add(new FEAttribute { Name = "全局" }); svr.Register <ApiSession>(); svr.Register <HelloController>(); var ns = svr.Servers[0] as NetServer; ns.LogSend = true; ns.LogReceive = true; svr.Start(); Console.ReadKey(); }