private static void JServer_OnReceive(JServer arg1, string arg2, JT808Package arg3) { var body = arg3.Bodies as JT808_0x0200; Console.ForegroundColor = ConsoleColor.DarkGreen; Console.WriteLine($"server 收到位置信息汇报,lng:{body.Lng},lat:{body.Lat},time:{body.GPSTime}"); Console.WriteLine($"server 发送应答,ManualMsgNum:101"); arg1.SendAsync(arg2, GetJT808ResponseData()); }
static void Main(string[] args) { Console.Title = "SAEA.Sockets.TcpTest JT808"; //jserver JServer jServer = new JServer(); jServer.OnReceive += JServer_OnReceive; jServer.Start(); //jclient JClient jClient = new JClient(); jClient.OnReceive += JClient_OnReceive; jClient.Connect(); jClient.SendAsync(GetJT808PositionData()); Console.ReadLine(); }
static void Main(string[] args) { Console.Title = "SAEA.Sockets.TcpTest JT808"; //jserver JServer jServer = new JServer(); jServer.OnReceive += JServer_OnReceive; jServer.Start(); //jclient JClient jClient1 = new JClient(); jClient1.OnReceive += JClient_OnReceive; jClient1.Connect(); for (int i = 0; i < 10; i++) { jClient1.SendAsync(GetJT808PositionData()); Thread.Sleep(500); } jClient1.Disconnect(); //jclient JClient2 jClient2 = new JClient2(); jClient2.Connect(); for (int i = 0; i < 10; i++) { jClient2.Send(GetJT808PositionData()); Thread.Sleep(1000); var data = jClient2.Receive(); Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine($"client 收到平台通用应答,MsgNum:{data.Header.MsgNum}"); } jClient2.Disconnect(); Console.ReadLine(); }