diff --git a/event_sender.go b/event_sender.go index d1aa8d4..f283992 100644 --- a/event_sender.go +++ b/event_sender.go @@ -10,6 +10,7 @@ import ( "log" "reflect" "sync" + "time" ) var ( @@ -40,18 +41,27 @@ func GetInstance() *EventSender { func init() { ch := make(chan interface{}, 0) - observer.Add(messages.CONFIGMANAGER_LOADED, ch) - handleInit(ch) + ch1 := make(chan interface{}, 0) + observer.Add(messages.CFG_LOADED, ch) + observer.Add(messages.SCF_STOPPED,ch1) + handleInit(ch, ch1) } -func handleInit(ch chan interface{}) { +func handleInit(ch chan interface{}, ch1 chan interface{}) { es := GetInstance() go func() { data := <-ch log.Println("handleInit", data) //ds.gconf = data.(cm.ConfigManager).GetGlobalConfig() es.start() - close(ch) + observer.Remove(messages.CFG_LOADED, ch) + }() + + go func() { + data := <- ch1 + observer.Notify(messages.QUEUE_DATA, data) + time.Sleep(2*time.Second) + es.Stop() }() }