ITimeModule.cs 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using System;
  2. namespace XGame.Framework.Time
  3. {
  4. public interface ITimeModule
  5. {
  6. /// <summary>
  7. /// 获取当前服务端or客户端时间戳(单位:毫秒,默认获取服务端时间)
  8. /// </summary>
  9. /// <param name="clockTyp">时钟类型(客户端时间or服务端时间,默认服务端时间)</param>
  10. /// <returns></returns>
  11. long GetNowTime(ClockType clockTyp = ClockType.Server);
  12. /// <summary>
  13. /// 设置服务端or客户端时间戳(默认设置服务端时间)
  14. /// </summary>
  15. /// <param name="timestamp">时间戳(毫秒)</param>
  16. /// <param name="clockTyp">时钟类型(客户端时间or服务端时间,默认服务端时间)</param>
  17. void SetTime(long timestamp, ClockType clockTyp = ClockType.Server);
  18. /// <summary>
  19. /// 添加闹钟(默认使用服务端时间)
  20. /// </summary>
  21. /// <param name="triggerTimestamp">结束时间戳(毫秒)</param>
  22. /// <param name="action">回调</param>
  23. /// <param name="clockTyp">时钟类型(客户端时间or服务端时间,默认服务端时间)</param>
  24. /// <returns>此闹钟</returns>
  25. IAlarm AddAlarm(Action action, long triggerTimeStamp, ClockType clockTyp = ClockType.Server);
  26. /// <summary>
  27. /// 添加计时器(使用客户端时间)
  28. /// </summary>
  29. /// <param name="delay">延时,单位:毫秒</param>
  30. /// <param name="action">回调</param>
  31. /// <returns>此计时器</returns>
  32. ITimer AddDelayTimer(int delay, Action action);
  33. /// <summary>
  34. /// 添加循环定时器(使用客户端时间)
  35. /// </summary>
  36. /// <param name="interval">循环间隔,单位:毫秒</param>
  37. /// <param name="action">触发事件,参数为循环的次数</param>
  38. /// <param name="loopTimes">循环次数(-1为无限,0和1都是1次)</param>
  39. /// <returns>定时器</returns>
  40. ITimer AddLooperTimer(int interval, Action<int> action, int loopTimes = -1);
  41. /// <summary>
  42. /// 添加循环定时器(使用客户端时间)
  43. /// </summary>
  44. /// <param name="delay">延迟,单位:毫秒</param>
  45. /// <param name="interval">循环间隔,单位:毫秒</param>
  46. /// <param name="action">触发事件</param>
  47. /// <param name="loopTimes">循环次数(-1为无限,0和1都是1次)</param>
  48. ITimer AddDelayLooperTimer(int delay, int interval, Action<int> action, int loopTimes = -1);
  49. }
  50. }