protected override void Setup() { Instance = this; InitHandlerDict(); log4net.GlobalContext.Properties["Photon:ApplicationLogPath"] = Path.Combine(Path.Combine(this.ApplicationRootPath, "bin_Win64"), "log"); string path = Path.Combine(this.BinaryPath, "log4net.config"); FileInfo configuratorFile = new FileInfo(path); if (configuratorFile.Exists) { LogManager.SetLoggerFactory(ExitGames.Logging.Log4Net.Log4NetLoggerFactory.Instance); XmlConfigurator.ConfigureAndWatch(configuratorFile); } Log.Info("服务器启动"); User user = Usermanager.GetById(3); Log.Info("username为" + user.Username); syncPositionEventThread.Run(); }
MyServer server; // объект сервера public MyClient(TcpClient tcpClient, MyServer serverObject) { Id = Guid.NewGuid().ToString(); client = tcpClient; server = serverObject; serverObject.AddConnection(this); }
static Thread listenThread; // потока для прослушивания static void Main(string[] args) { try { server = new MyServer(); listenThread = new Thread(new ThreadStart(server.Listen)); listenThread.Start(); //старт потока } catch (Exception ex) { server.Disconnect(); Console.WriteLine(ex.Message); } }
static void Main(string[] args) { ICrudRepository <int, Game> gameRepo = new GameRepository(); ICrudRepository <int, Ticket> ticketRepo = new TicketRepository(); ICrudRepository <int, Seller> sellerRepo = new SellerRepository(); GameService gameService = new GameService(gameRepo); TicketService ticketService = new TicketService(ticketRepo); SellerService sellerService = new SellerService(sellerRepo); IServer serverImpl = new ServerImplement(gameService, ticketService, sellerService); foreach (Seller s in sellerService.findAll()) { Console.WriteLine(s); Console.WriteLine(s.Id); } MyServer server = new MyServer("127.0.0.1", 55560, serverImpl); server.Start(); Console.WriteLine("Server started ..."); Console.WriteLine("Press <enter> to exit..."); Console.ReadLine(); }