package crawler_manager

import (
	"loafle.com/overflow/agent_api/observer"
	"loafle.com/overflow/agent_api/config_manager"
	"loafle.com/overflow/agent_api/observer/messages"

	"fmt"
)


func listenEvent() {

	go listenConfigLoaded();
	go listenAddSensor();

}

func listenConfigLoaded() {

	ch := make(chan interface{}, 0)
	observer.Add(messages.CONFIGMANAGER_LOADED, ch)

	o := <-ch

	cm := o.(config_manager.ConfigManager)

	GetInstance().ConfigMgr = cm;

	GetInstance().init();

}

func listenAddSensor() {
	ch := make(chan interface{}, 0)
	observer.Add(messages.ADD_SENSOR_1, ch);

	o := <-ch

	str := o.(string)

	fmt.Println(str)
	//GetInstance().Addconfig(str)
}

