/// <summary> /// Add the specified message, beginTime, endTime, isCycle and secondInterval. /// </summary> /// <param name="message">Message.</param> /// <param name="beginTime">Begin time.</param> /// <param name="endTime">End time.</param> /// <param name="isCycle">If set to <c>true</c> is cycle.</param> /// <param name="secondInterval">Second interval.</param> public void Add(NoticeMessage message, string beginTime, string endTime, bool isCycle, int secondInterval) { PlanConfig planConfig = null; if (isCycle) { planConfig = PlanConfig.EveryMinutePlan(DoBroadcast, "BroadcastTimer", beginTime, endTime, secondInterval); } else { planConfig = PlanConfig.OncePlan(DoBroadcast, "BroadcastTimer", beginTime); } planConfig.Target = message; TimeListener.Append(planConfig); }
public static void Dispatcher(PlanConfig planconfig) { if (ScriptEngines.IsCompiling) { return; } if (MsgList.Count <= 0) { return; } int count = Math.Min(MsgList.Count, 100); var list = MsgList.GetListRange(0, count); foreach (var v in list) { v.IsRemove = true; GameSession session = GameSession.Get(v.UserId); if (session != null && session.Connected && v.Param != null) { switch (v.Type) { case MsgType.Chat: { var packet = ActionFactory.GetResponsePackage(ActionIDDefine.Cst_Action2000, session, v.Param, OpCode.Text, null ); ActionFactory.SendAction(session, ActionIDDefine.Cst_Action2000, packet, (rsession, asyncResult) => { }, 0); } break; case MsgType.Notice: { var packet = ActionFactory.GetResponsePackage(ActionIDDefine.Cst_Action2001, session, v.Param, OpCode.Text, null ); ActionFactory.SendAction(session, ActionIDDefine.Cst_Action2001, packet, (rsession, asyncResult) => { }, 0); } break; } } } MsgList.RemoveAll(t => t.IsRemove == true); }
private void DoBroadcast(PlanConfig planConfig) { if (_isRunning == 1) { return; } Interlocked.Exchange(ref _isRunning, 1); //TraceLog.ReleaseWrite("{0}>>Broadcast listener start...", DateTime.Now.ToLongTimeString()); if (planConfig.Target is NoticeMessage) { NoticeMessage message = planConfig.Target as NoticeMessage; if (_callback != null) { _callback(message); } } Interlocked.Exchange(ref _isRunning, 0); }
void init() { bool openDebug = GameConfigMgr.Instance().getInt("timer_open_debug", 0) == 1; if (openDebug) { string debugParm = GameConfigMgr.Instance().getString("timer_user_ranking_clear", "330000,330000"); string[] words = debugParm.Split(','); TimerMgr.Singleton().add("RankingClear", ccccc, int.Parse(words[0]), int.Parse(words[1])); } else { string theStr = GameConfigMgr.Instance().getString("timer_user_ranking_clear_timming", "05:00"); //每天0点执行 TimeListener.Append(PlanConfig.EveryDayPlan(DoEveryWeekExecute, "EveryDayTask", theStr)); ConsoleLog.showNotifyInfo("timer_user_ranking_clear_timming begin:" + theStr); } }
public sortMethod(sortType t, string parm, PlanCallback f) { _f = f; if (sortType.None == t) { } else if (sortType.Interval == t) { string [] p = parm.Split(','); int p1 = 0, p2 = 0; try { p1 = int.Parse(p[0]); p2 = int.Parse(p[1]); } catch (Exception e) { p1 = 1000; p2 = 1000 * 60 * 60; } _timer = new Timer(timeCb, null, p1, p2); } else if (sortType.Timing == t) { string[] timers = parm.Split(','); for (int i = 0; i < timers.Length; ++i) { try { DateTime dt = Convert.ToDateTime(timers[i]); } catch (Exception e) { ConsoleLog.showErrorInfo(i, e.Message + ":datePase Error;" + timers[i]); continue; } TimeListener.Append(PlanConfig.EveryDayPlan(_f, "EveryDayTask", timers[i])); } } else if (sortType.week == t) { } }
public static void LoopAction(PlanConfig planconfig) { if (ScriptEngines.IsCompiling) { return; } //do something TransferExpireCheckInterval++; if (TransferExpireCheckInterval > 10) { TransferExpireCheckInterval = 0; var onlinelist = UserHelper.GetOnlinesList(); foreach (var usersession in onlinelist) { UserHelper.TransferExpireCheck(usersession.UserId); UserHelper.ElfExperienceExpireCheck(usersession.UserId); } } AutoFight.FightResponse(); LoopNoticeInterval++; if (LoopNoticeInterval > 600) { LoopNoticeInterval = 0; //string context = "尊敬的各位玩家,勇者之怒将于今天下午16点整删档测试结束后关闭服务器," // + "感谢您对本次测试的支持。请您记好游戏昵称以及ID,联系客服 2602611792 进行奖励兑换,谢谢!"; //string context = "本次测试充值的玩家,在测试结束后,正式服享受充值3倍钻石返还优惠,机不可失失不再来,快来一起闯关吧!"; //GlobalRemoteService.SendNotice(NoticeMode.AllService, context); } //Ranking<GuildRank> guildRanking = RankingFactory.Get<GuildRank>(GuildRanking.RankingKey); //guildRanking.ForceRefresh(); //if (competition64 != null) // competition64.Run(); //CombineZone.Run(); }
protected override void OnStartAffer() { TimeListener.Append(PlanConfig.EveryMinutePlan(MsgDispatcher.Dispatcher, "Dispatcher", "00:00", "23:59", 1)); TimeListener.Append(PlanConfig.EveryMinutePlan(DoEveryDayRefreshDataTask, "EveryDayRefreshDataTask", "00:00", "23:59", 600)); //TimeListener.Append(PlanConfig.EveryDayPlan(DoEveryDayRefreshDataTask, "EveryDayRefreshDataTask", "03:10")); ServerSet.LoadServerConfig(); RankingFactory.Add(new LevelRanking()); //RankingFactory.Add(new GuildRanking()); RankingFactory.Start(60); // 设置竞技场排行不刷新 Ranking <UserRank> levelRanking = RankingFactory.Get <UserRank>(LevelRanking.RankingKey); levelRanking.SetIntervalTimes(int.MaxValue); //// 设置公会排行不刷新 //Ranking<GuildRank> guildRanking = RankingFactory.Get<GuildRank>(GuildRanking.RankingKey); //guildRanking.SetIntervalTimes(int.MaxValue); LevelRankingAllServerSet.LoadServerRanking(); }
public void Initialize(PlanConfig planConfig) { var locations = new List <PAI.FRATIS.SFL.Domain.Geography.Location>(); var routeStops = planConfig.Jobs.Select(p => p.RouteStops).ToList(); var locationsSet = new HashSet <Domain.Geography.Location>(); foreach (var routeStopList in routeStops.ToList()) { foreach (var rs in routeStopList) { locationsSet.Add(rs.Location); } } foreach (var driver in planConfig.Drivers) { if (driver.StartingLocation != null) { locationsSet.Add(driver.StartingLocation); } } _locationDistanceService.Prefetch(locationsSet.ToList()); }
public static void Run() { //AppstoreClientManager.Current.InitConfig(); //var dispatch = TaskDispatch.StartTask(); //dispatch.Add(new StudyTask()); lock (thisLock) { _isRunning = false; } Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); #if NO_MERGE_SERVICE_DATA var httpHost = GetSection().HttpHost; var httpPort = GetSection().HttpPort; var httpName = GetSection().HttpName; if (!string.IsNullOrEmpty(httpHost)) { var names = httpName.Split(','); new NewHttpListener(httpHost, httpPort, new HashSet <string>(names)); } LoadGlobalData(); // 上传该服务器的状态 TimeListener.Append(PlanConfig.EveryMinutePlan(submitServerStatus, "submitServerStatus", "00:00", "23:59", ConfigurationManager.AppSettings["ServerStatusSendInterval"].ToInt())); // 自动机器人,64争霸赛 TimeListener.Append(PlanConfig.EveryMinutePlan(LoopAction, "LoopAction", "00:00", "23:59", 3)); // new GameActiveCenter(null); // new GuildGameActiveCenter(null); //每天执行用于整点刷新 TimeListener.Append(PlanConfig.EveryDayPlan(UserHelper.DoZeroRefreshDataTask, "DoZeroRefreshDataTask", "00:00")); //TimeListener.Append(PlanConfig.EveryMinutePlan(UserHelper.DoZeroRefreshDataTask, "DoZeroRefreshDataTask", "08:00", "22:00", 60)); //每天5点执行用于整点刷新 TimeListener.Append(PlanConfig.EveryDayPlan(UserHelper.DoEveryDayRefreshDataTask, "EveryDayRefreshDataTask", "05:00")); // 每周二,周五 TimeListener.Append(PlanConfig.EveryWeekPlan(UserHelper.DoTuesdayRefreshTask, "TuesdayRefreshTask", DayOfWeek.Tuesday, "04:00")); //TimeListener.Append(PlanConfig.EveryWeekPlan(UserHelper.DoFridayRefreshTask, "FridayRefreshTask", DayOfWeek.Friday, "04:00")); DataHelper.InitData(); InitRanking(); if (DataHelper.IsFirstOpenService) { string ncikName = string.Empty; var botsNameSet = new ShareCacheStruct <Config_BotsName>(); for (int i = 0; i < 5; ++i) { ncikName = botsNameSet.FindKey(random.Next(botsNameSet.Count)).String; ncikName += botsNameSet.FindKey(random.Next(botsNameSet.Count)).Value; UserCenterUser ucu = Util.CreateUserCenterUser(Util.GetRandomGUIDPwd(), "0000", GameEnvironment.ProductServerId); Action1005.CreateRole(ucu.UserID, "", ucu.ServerID, ucu.OpenID, ucu.RetailID, ncikName, random.Next(1) + 1, ""); } } //Bots.InitBots(); //if (competition64 == null) //{ // competition64 = new Competition64(); // competition64.Initialize(); //} GlobalRemoteService.Reuest(); stopwatch.Stop(); new BaseLog().SaveLog("系统全局运行环境加载所需时间:" + stopwatch.Elapsed.TotalMilliseconds + "ms"); SendServerStatus(ServerStatus.Unhindered, 0); #else MERGE_SERVICE.Run(); #endif lock (thisLock) { _isRunning = true; } }
public static void Init() { PlanConfig planConfig = new PlanConfig(Rank, true, ConfigEnvSet.GetInt("Rank.SJT"), ""); TimeListener.Append(planConfig); }
public static void DoEveryDayExecute(PlanConfig planconfig) { RealItemCntUpdate.Instance().action_HappyModeData_enterNum(null); }
private static void DoEveryWeekExecute(PlanConfig planconfig) { RankingClear.Instance().doIt(); }
public virtual void StartServer() { //每天0点执行 TimeListener.Append(PlanConfig.EveryDayPlan(DoEveryDayExecute, "EveryDayTask", "00:00")); }