Esempio n. 1
0
func main() {
	logger.Info("Go router running \r\n")
	//init logger
	logger.GetLogger().SetLogLevel(5, 5)
	logger.GetLogger().SetOutputDir(`c:\`)
	logger.GetLogger().Init("testlog")

	//init tcp server
	logger.Info("Go run TCPServer \r\n")
	tcpServer := server.NewTCPServer("tcp", ":9093")

	//setup handler
	tcpServer.GetRouter().SetConnHandler(&ConnHandlerImpl{})
	tcpServer.GetRouter().SetDisconHandler(&DisconHandlerImpl{})
	//register handler
	tcpServer.GetRouter().SetTcpHandler(map[uint8]router.Handler{
		0x0: &MyHandlerImpl{},
	})
	//register Ipc handler
	tcpServer.GetRouter().SetIpcHandler(map[string]router.IpcHandler{})

	//startup
	tcpServer.Run()

	<-exitChan
}
Esempio n. 2
0
func Test_Redis(t *testing.T) {
	logger.GetLogger().SetLogLevel(5, 5)
	logger.GetLogger().SetOutputDir(`c:\`)
	logger.GetLogger().Init("testlog")

	rd := NewRedis()
	rd.Init()
	ret, _ := rd.Pool().Get().Do("GET", "abc")

	fmt.Printf("redis test running %v\n", ret)
	for {
		v := GetCached().Do("get", "abc")
		fmt.Printf("testing v =%v  \n", v)
		time.Sleep(1 * time.Second)
	}

}
Esempio n. 3
0
func main() {
	logger.Info("Go router running \r\n")
	//init logger
	logger.GetLogger().SetLogLevel(5, 5)
	logger.GetLogger().SetOutputDir(`c:\`)
	logger.GetLogger().Init("testlog")

	logger.Info("Go run WSServer \r\n")

	wsServer := server.NewWSServer(":9092")
	//register handler
	wsServer.GetRouter().SetWsHandler(map[string]router.WSHandler{
		"system": &WsUserHandlerImpl{},
		"user":   &WsUserHandlerImpl{},
		"chat":   &WsUserHandlerImpl{},
	})

	//startup
	wsServer.Run()

	<-exitChan
}