Exemple #1
0
 private void InitServerMS(ServerConfigInfo info)
 {
     if (_serverConfig.isMaster)
     {
         InitNetServer(ref _netServerMS, info.masterPort);
     }
 }
        public static void RunServer <T>(ServerConfigInfo config)
            where T : BaseServer, new()
        {
            long lastTick     = 1;
            int  tickInterval = 40;

            Console.WriteLine("=============== LockstepPlatform " + config.type + " Start!! ===============");
            Console.WriteLine("config: " + config.ToString());
            var sw = new Stopwatch();

            sw.Start();
            StartServices();
            Debug.prefix = typeof(T).Name + ":";
            BaseServer server = new T();
            {
                server.DoAwake(config);
                server.DoStart();
                while (!Console.KeyAvailable)
                {
                    server.PollEvents();
                    var curTick = sw.ElapsedMilliseconds;
                    var elapse  = curTick - lastTick;
                    if (elapse >= tickInterval)
                    {
                        lastTick = curTick;
                        UpdateServices();
                        server.DoUpdate((int)elapse);
                    }

                    Thread.Sleep(1);
                }
            }
        }
 private void InitServerMS(ServerConfigInfo info)
 {
     if (_serverConfig.isMaster)
     {
         InitNetServer(ref _netServerMS, info.masterPort, (peer) => new ServerProxy(peer));
     }
 }
 public virtual void DoAwake(ServerConfigInfo info)
 {
     IP                    = NetworkHelper.GetLocalIP();
     serverType            = info.type;
     _allConfig            = ServerUtil.LoadConfig();
     _allConfig.daemonPort = _allConfig.GetServerConfig(EServerType.DaemonServer).serverPort;
     _serverConfig         = info;
     masterType            = _allConfig.isMaster ? EMasterType.Master : EMasterType.Slave;
 }
 public virtual void DoAwake(ServerConfigInfo info)
 {
     Debug                 = new DebugInstance(GetType().Name + ": ");
     HasInit               = true;
     Ip                    = NetworkHelper.GetLocalIP();
     serverType            = info.type;
     _allConfig            = ServerUtil.LoadConfig();
     _allConfig.DeamonPort = _allConfig.GetServerConfig(EServerType.DaemonServer).serverPort;
     _serverConfig         = info;
     masterType            = _allConfig.isMaster ? EMasterType.Master : EMasterType.Slave;
 }