예제 #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
}