예제 #1
0
        void Application_Start(object sender, EventArgs e)
        {
            // Code that runs on application startup
            //AreaRegistration.RegisterAllAreas();
            //GlobalConfiguration.Configure(WebApiConfig.Register);
            //RouteConfig.RegisterRoutes(RouteTable.Routes);

            log4net.Config.XmlConfigurator.Configure();

            m_container = GameServerContainer.Instance;
            m_container.Run();

            MatchServer.StartGCThread();
        }
예제 #2
0
        public void SaveReplay(Guid clientId, string name, ServerEventHandler callback)
        {
            MatchServer.GetReplay(clientId, (error, replayData, room) =>
            {
                if (HasError(error))
                {
                    callback(error);
                    return;
                }

                ReplayInfo replayInfo  = new ReplayInfo();
                replayInfo.DateTime    = DateTime.UtcNow.Ticks;
                replayInfo.Name        = name;
                replayInfo.Id          = replayData.Id = Guid.NewGuid();
                replayInfo.MapId       = Room.MapInfo.Id;
                replayInfo.PlayerNames = Room.Players.Skip(1).Select(r => m_players[r].Name).ToArray();

                error.Code = StatusCode.OK;

                string dataPath = m_persistentDataPath + "/Replays/";
                if (!Directory.Exists(dataPath))
                {
                    Directory.CreateDirectory(dataPath);
                }

                byte[] replayInfoBytes = m_serializer.Serialize(replayInfo);

                File.WriteAllBytes(dataPath + replayInfo.Id + ".info", replayInfoBytes);

                byte[] replayDataBytes = m_serializer.Serialize(replayData);

                File.WriteAllBytes(dataPath + replayData.Id + ".data", replayDataBytes);

                if (m_lag == 0)
                {
                    callback(error);
                }
                else
                {
                    Job.Submit(() => { Thread.Sleep(m_lag); return(null); }, result => callback(error));
                }
            });
        }
예제 #3
0
        void Application_End()
        {
            MatchServer.StopGCThread();

            m_container.Stop();
        }