no message
This commit is contained in:
parent
fcdb12669c
commit
93134b7f57
|
@ -6,6 +6,10 @@ import (
|
||||||
"mongo.games.com/goserver/core/module"
|
"mongo.games.com/goserver/core/module"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
module.RegisteModule(ClockMgrSingleton, time.Millisecond*500, 0)
|
||||||
|
}
|
||||||
|
|
||||||
var ClockMgrSingleton = &ClockMgr{
|
var ClockMgrSingleton = &ClockMgr{
|
||||||
LastHour: -1,
|
LastHour: -1,
|
||||||
LastDay: -1,
|
LastDay: -1,
|
||||||
|
@ -99,9 +103,9 @@ func (this *ClockMgr) Update() {
|
||||||
this.LastSec = sec
|
this.LastSec = sec
|
||||||
this.fireSecondEvent()
|
this.fireSecondEvent()
|
||||||
|
|
||||||
min := tNow.Minute()
|
minute := tNow.Minute()
|
||||||
if min != this.LastMini {
|
if minute != this.LastMini {
|
||||||
this.LastMini = min
|
this.LastMini = minute
|
||||||
this.fireMinuteEvent()
|
this.fireMinuteEvent()
|
||||||
|
|
||||||
hour := tNow.Hour()
|
hour := tNow.Hour()
|
||||||
|
@ -182,6 +186,87 @@ func (this *ClockMgr) GetLast() (int, int, int, int, int, int) {
|
||||||
return this.LastSec, this.LastMini, this.LastHour, this.LastDay, this.LastWeek, int(this.LastMonth)
|
return this.LastSec, this.LastMini, this.LastHour, this.LastDay, this.LastWeek, int(this.LastMonth)
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
type ClockFunc struct {
|
||||||
module.RegisteModule(ClockMgrSingleton, time.Millisecond*500, 0)
|
event int
|
||||||
|
OnSecTimerFunc func()
|
||||||
|
OnMiniTimerFunc func()
|
||||||
|
OnHourTimerFunc func()
|
||||||
|
OnDayTimerFunc func()
|
||||||
|
OnWeekTimerFunc func()
|
||||||
|
OnMonthTimerFunc func()
|
||||||
|
OnShutdownFunc func()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ClockFunc) InterestClockEvent() int { return s.event }
|
||||||
|
|
||||||
|
func (s *ClockFunc) OnSecTimer() {
|
||||||
|
if s.OnSecTimerFunc != nil {
|
||||||
|
s.OnSecTimerFunc()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ClockFunc) OnMiniTimer() {
|
||||||
|
if s.OnMiniTimerFunc != nil {
|
||||||
|
s.OnMiniTimerFunc()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ClockFunc) OnHourTimer() {
|
||||||
|
if s.OnHourTimerFunc != nil {
|
||||||
|
s.OnHourTimerFunc()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ClockFunc) OnDayTimer() {
|
||||||
|
if s.OnDayTimerFunc != nil {
|
||||||
|
s.OnDayTimerFunc()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ClockFunc) OnWeekTimer() {
|
||||||
|
if s.OnWeekTimerFunc != nil {
|
||||||
|
s.OnWeekTimerFunc()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ClockFunc) OnMonthTimer() {
|
||||||
|
if s.OnMonthTimerFunc != nil {
|
||||||
|
s.OnMonthTimerFunc()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ClockFunc) OnShutdown() {
|
||||||
|
if s.OnShutdownFunc != nil {
|
||||||
|
s.OnShutdownFunc()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// RegisterClockFunc 注册时钟事件
|
||||||
|
func RegisterClockFunc(fs *ClockFunc) {
|
||||||
|
if fs == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if fs.OnSecTimerFunc != nil {
|
||||||
|
fs.event = fs.event ^ ClockEventSecond
|
||||||
|
}
|
||||||
|
if fs.OnMiniTimerFunc != nil {
|
||||||
|
fs.event = fs.event ^ ClockEventMinute
|
||||||
|
}
|
||||||
|
if fs.OnHourTimerFunc != nil {
|
||||||
|
fs.event = fs.event ^ ClockEventHour
|
||||||
|
}
|
||||||
|
if fs.OnDayTimerFunc != nil {
|
||||||
|
fs.event = fs.event ^ ClockEventDay
|
||||||
|
}
|
||||||
|
if fs.OnWeekTimerFunc != nil {
|
||||||
|
fs.event = fs.event ^ ClockEventWeek
|
||||||
|
}
|
||||||
|
if fs.OnMonthTimerFunc != nil {
|
||||||
|
fs.event = fs.event ^ ClockEventMonth
|
||||||
|
}
|
||||||
|
if fs.OnShutdownFunc != nil {
|
||||||
|
fs.event = fs.event ^ ClockEventShutdown
|
||||||
|
}
|
||||||
|
|
||||||
|
ClockMgrSingleton.RegisterSinker(fs)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue