示例#1
0
文件: chat.go 项目: rand99/taillachat
// Runs when user is ready to chat
func ChatReady(sessionId string, region string) {
	cs := ChatSessions.Get(sessionId)
	if cs != nil {
		ChatSessions.Action(func() {
			cs.Region = region
			cs.IsReady = true
		})
	}

	// Let's find match
	partner := ChatFindMatch(sessionId, region)

	if partner != nil {
		// Let's create a chat!
		ChatSessions.Action(func() {
			glog.Info("Chat session started")
			cs.IsReady = false
			partner.IsReady = false

			room := &ChatRoom{
				Sessions: []*ChatSession{cs, partner},
			}

			cs.Room = room
			partner.Room = room

			room.Broadcast("join", "")
			room.BroadcastOthers(cs.Id, "message", helpers.Parse(Template, "chat/join", cs))
			room.BroadcastOthers(partner.Id, "message", helpers.Parse(Template, "chat/join", partner))
		})

	}
}
示例#2
0
文件: main.go 项目: rand99/taillachat
func (controller *MainController) Privacy(c web.C, r *http.Request) (string, int) {
	t := controller.GetTemplate(c)

	c.Env["Title"] = "Tailla Chat - Best UK Chat - Privacy"

	widgets := helpers.Parse(t, "privacy", nil)

	c.Env["Content"] = template.HTML(widgets)

	return helpers.Parse(t, "main", c.Env), http.StatusOK
}
示例#3
0
文件: main.go 项目: rand99/taillachat
func (controller *MainController) Index(c web.C, r *http.Request) (string, int) {
	t := controller.GetTemplate(c)

	widgets := helpers.Parse(t, "home", nil)

	c.Env["Content"] = template.HTML(widgets)

	c.Env["Title"] = "Tailla Chat - Best UK Chat"
	c.Env["SocketURL"] = "/chat"

	return helpers.Parse(t, "main", c.Env), http.StatusOK
}