Esempio n. 1
0
func main() {
	runtime.GOMAXPROCS(runtime.NumCPU())

	flag.Parse()

	c, err := iniconfig.ReadConfigFile(*logicConf)
	if err != nil {
		gts.Error(err.Error())
		return
	}

	var endianer gts.IEndianer
	section := "Default"
	endian, err := c.GetInt(section, "endian")
	if err == nil {
		endianer = gts.GetEndianer(endian)
	} else {
		endianer = gts.GetEndianer(gts.LittleEndian)
	}
	routepack := wormhole.NewRoutePack(endianer)
	wormholes := server.NewAgentManager(routepack)

	logic := server.NewLogicFromIni(c, routepack, wormholes, NewLogicToAgent)

	logic.ConnectFromIni(c)

	gts.Info("----------------logic server is running!-----------------", logic.GetServerId())

	quit := make(chan bool)
	go exit(quit)

	<-quit
}
Esempio n. 2
0
func main() {
	runtime.GOMAXPROCS(runtime.NumCPU())

	flag.Parse()

	c, err := iniconfig.ReadConfigFile(*clientConf)
	if err != nil {
		gts.Error(err.Error())
		return
	}

	section := "Default"

	logconf, err := c.GetString(section, "logConfigFile")
	if err != nil {
		logconf = ""
	}
	gts.SetLogger(&logconf)

	clientTcpAddr, err := c.GetString(section, "clientTcpAddr")
	if err != nil {
		gts.Error(err.Error())
		return
	}

	var endianer gts.IEndianer
	endian, err := c.GetInt(section, "endian")
	if err == nil {
		endianer = gts.GetEndianer(endian)
	} else {
		endianer = gts.GetEndianer(gts.LittleEndian)
	}
	routepack := wormhole.NewRoutePack(endianer)
	var cwormholes wormhole.IWormholeManager

	client = wormhole.NewClient(clientTcpAddr, routepack, cwormholes, NewClientWormhole, wormhole.EWORMHOLE_TYPE_CLIENT)
	client.Connect()

	gts.Info("----------------client connect to %s,%s-----------------", clientTcpAddr)

	quit := make(chan bool)
	go exit(quit)

	<-quit
}
Esempio n. 3
0
func main() {
	runtime.GOMAXPROCS(runtime.NumCPU())

	flag.Parse()

	c, err := iniconfig.ReadConfigFile(*agentConf)
	if err != nil {
		gts.Error(err.Error())
		return
	}

	var endianer gts.IEndianer
	section := "Default"
	endian, err := c.GetInt(section, "endian")
	if err == nil {
		endianer = gts.GetEndianer(endian)
	} else {
		endianer = gts.GetEndianer(gts.LittleEndian)
	}
	routepack := wormhole.NewRoutePack(endianer)

	cwormholes := wormhole.NewWormholeManager(routepack, wormhole.MAX_CONNECTIONS, wormhole.EWORMHOLE_TYPE_CLIENT)

	dispatcher := server.NewDispatcher(routepack)
	lwormholes := server.NewLogicManager(routepack, dispatcher)
	agent := server.NewAgentFromIni(c, routepack, cwormholes, lwormholes, server.NewAgentToClientWormhole, server.NewAgentToLogicWormhole)

	agent.Start()

	gts.Info("----------------agent server is running!-----------------", agent.GetServerId())

	quit := make(chan bool)
	go exit(quit)

	<-quit
}