本文整理匯總了Golang中github.com/ginuerzh/sports/models.RedisLogger.JoinGroup方法的典型用法代碼示例。如果您正苦於以下問題:Golang RedisLogger.JoinGroup方法的具體用法?Golang RedisLogger.JoinGroup怎麽用?Golang RedisLogger.JoinGroup使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/ginuerzh/sports/models.RedisLogger
的用法示例。
在下文中一共展示了RedisLogger.JoinGroup方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: setGroupHandler
func setGroupHandler(request *http.Request, resp http.ResponseWriter,
redis *models.RedisLogger, user *models.Account, p Parameter) {
form := p.(setGroupForm)
group := &models.Group{
Gid: form.Id,
Name: form.Name,
Profile: form.Profile,
Desc: form.Desc,
Creator: user.Id,
Time: time.Now(),
}
if form.Address.String() != "" {
group.Addr = &form.Address
loc := models.Addr2Loc(form.Address)
group.Loc = &loc
}
var err error
if len(form.Id) == 0 {
err = group.Save()
if err == nil {
redis.JoinGroup(user.Id, group.Gid, true)
}
} else {
err = group.Update()
}
writeResponse(request.RequestURI, resp, map[string]string{"group_id": group.Gid}, err)
}
示例2: joinGroupHandler
func joinGroupHandler(request *http.Request, resp http.ResponseWriter,
redis *models.RedisLogger, user *models.Account, p Parameter) {
form := p.(joinGroupForm)
redis.JoinGroup(user.Id, form.Gid, !form.Leave)
writeResponse(request.RequestURI, resp, nil, nil)
event := &models.Event{
Type: "message",
Data: models.EventData{
From: user.Id,
To: form.Gid,
},
}
if !form.Leave {
event.Data.Type = "subscribe"
} else {
event.Data.Type = "unsubscribe"
}
redis.PubMsg(event.Data.Type, user.Id, event.Bytes())
}