예제 #1
0
        public bool Start()
        {
            try
            {
                var loginConfig = new ServerConfig
                {
                    Port = ServerSettings.ServerPort,
                    Ip   = "127.0.0.1",
                    MaxConnectionNumber = ServerSettings.BacklogLimit,
                    Name = "登录服务器",
                };
                LoginServer.Setup(loginConfig);

                for (var i = 0; i < ServerSettings.ChannelCount; i++)
                {
                    var channel = new ChannelServer(i);
                    channel.Setup("127.0.0.1", ServerSettings.ChannelPort + i);
                    ChannelServers.Add(channel);
                }

                bool result = LoginServer.Start();
                ChannelServers.ForEach(x => { result = result && x.Start(); });
                isLaunched = result;
                return(result);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return(false);
            }
        }
예제 #2
0
 public void Stop()
 {
     if (isLaunched)
     {
         LoginServer.Stop();
         ChannelServers.ForEach(x => x.Stop());
         TimerManager.Instance.Stop();
     }
 }