private void StartServer(IPAddress localIP, int localPort) { if (server == null) { server = new SimulationServer(); server.Start(localIP, localPort); } if (serverThread == null) { serverThread = ThreadTool.Start(() => { while (true) { for (int i = 0; i < AreaCanvas1.PersonShapeList.Count; i++) { var ps = AreaCanvas1.PersonShapeList[i]; ps.SavePos(); var tPos = ps.Pos; var dbPos = tPos.ToDbModel(); Position pos = new Position(); pos.SetTime(); pos.SetProperty(dbPos); server.Send(pos.GetText()); } Thread.Sleep(250); } }); } }
private void StopServer() { if (server != null) { server.Stop(); server = null; } if (serverThread != null) { serverThread.Abort(); } }