static void Main(string[] args) { Console.WriteLine("Press any key to start.."); Console.ReadKey(); Server = new TcpChannel(); Timer = new Timer(OnTick, null, TimeSpan.Zero, TimeSpan.FromMilliseconds(50)); Server.EventInform += (s, e) => Console.WriteLine(e.Data.Message); Server.GetInform += (s, e) => Console.WriteLine("Got: {0}", e.Data.Value); Server.CheckInform += (s, e) => Console.WriteLine(e.Data.Success); Server.GetAllInform += (s, e) => { Console.WriteLine("Test: Data Coherence Test..."); foreach (var entity in e.Data.Table) { // Check the entity Server.Check(entity.Key, entity.Value); } }; Server.Connected += (s, e) => { Server.GetAll(); }; Server.Connect("127.0.0.1", 8002); Console.WriteLine("Press any key to exit.."); Console.ReadKey(); }
static void Main(string[] args) { var Server = new TcpChannel(1000000); Server.EventInform += (sender, packet) => Console.WriteLine(packet.Message); Server.GetInform += (sender, packet) => Console.WriteLine("Got: {0}", packet.Value); Server.CheckInform += (sender, packet) => { //if(!packet.Success) Console.WriteLine("[{0}] {1} => {2}", packet.Success ? "SUCCESS" : "FAIL", packet.Key, packet.Value); }; Server.GetAllInform += async (sender, packet) => { Console.WriteLine("Test: Data Coherence Test..."); foreach (var entity in packet.Table) await Server.Check(entity.Key, entity.Value); }; Server.Connected += async (sender) => { Console.WriteLine("Connected"); await sender.GetAll(); }; Server.Disconnected += (sender, error) => { Console.WriteLine("Disconnected : {0}", error); }; Task.Run(async () => await Server.Connect("127.0.0.1", 8002)); Console.WriteLine("Press any key to exit.."); Console.ReadKey(); Server.Disconnect(); }