Esempio n. 1
0
func init() {
	beego.Router("/", &controllers.MainController{})
	beego.Router("/home", &controllers.MainController{})

	beego.Router("/info", &controllers.InfoController{})
	beego.Router("/chat", &controllers.ChatController{})

	beego.Handler("/chat_websocket", websocket.Handler(models.ChatroomServer))
	// beego.Router("/b", &controllers.BController{})
}
Esempio n. 2
0
func init() {

	ch := models.NewChatHome()
	ch.InitGlobal()
	// connid = 0

	beego.Handler("/ws_chat", websocket.Handler(models.ChatroomServer))

	beego.Router("/", &controllers.MainController{})
	beego.Router("/login", &controllers.LoginController{})
	beego.Router("/chat_home", &controllers.ChatController{})

	log.Println("Router init Over")
}
Esempio n. 3
0
func (s *Server) Start() {
	// Start timeout loop here
	logger.Println("[Message] Idle player checker goroutine started")
	go s.TimeoutLoop()
	go g_game.CheckCreatures()

	// Open new socket listener
	logger.Println("Opening websocket server on :" + s.Port + "/puserver")

	logger.Println("Server ready to accept new connections")
	http.Handle("/puserver", websocket.Handler(ClientConnection))
	err := http.ListenAndServe(":"+s.Port, nil)
	if err != nil {
		panic("ListenAndServe: " + err.Error())
	}
}
Esempio n. 4
0
func main() {
	flag.Parse()

	portStrings := strings.Split(*ports, ",")

	availableNodes = make(chan int, *numNodes)

	for i, port := range portStrings {
		hostMap[i] = "localhost:" + port
		reverseHostMap["localhost:"+port] = i
		availableNodes <- i
	}

	http.Handle("/echo", websocket.Handler(echoHandler))
	http.HandleFunc("/index", indexHandler)
	http.Handle("/", http.FileServer(http.Dir(".")))
	err := http.ListenAndServe("localhost:8999", nil) //hostMap[*nodeID], nil)
	if err != nil {
		panic("ListenAndServe: " + err.Error())
	}
}
Esempio n. 5
0
func main() {
	http.Handle("/", websocket.Handler(CounterServer))
	if err := http.ListenAndServe(":5603", nil); err != nil {
		log.Fatalln(err)
	}
}