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") }
func (this *ChatController) Get() { ch := models.NewChatHome() this.Data["cookie"] = this.Ctx.Input.Cookie("achat") this.Data["online_count"] = ch.GetOnlineCount() this.Data["waitting_count"] = ch.GetWaittingCount() this.Data["max_online_count"] = ch.MAX_ONLINE_COUNT u, _ := models.NewUser("user1", "hero") this.Data["username"] = u.Name b, _ := ch.IsOnline(u.Name) this.Data["testData"] = b this.TplNames = "chat.tpl" }