本文整理匯總了Golang中github.com/ginuerzh/sports/models.RedisLogger.SetHeartRecv方法的典型用法代碼示例。如果您正苦於以下問題:Golang RedisLogger.SetHeartRecv方法的具體用法?Golang RedisLogger.SetHeartRecv怎麽用?Golang RedisLogger.SetHeartRecv使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/ginuerzh/sports/models.RedisLogger
的用法示例。
在下文中一共展示了RedisLogger.SetHeartRecv方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: recvHeartHandler
func recvHeartHandler(r *http.Request, w http.ResponseWriter,
redis *models.RedisLogger, user *models.Account, p Parameter) {
form := p.(recvHeartForm)
// ws push
event := &models.Event{
Type: models.EventSystem,
Time: time.Now().Unix(),
Data: models.EventData{
Type: models.EventRecvHeart,
Id: user.Id,
From: user.Id,
To: form.Sender,
Body: []models.MsgBody{
{Type: "userid", Content: user.Id},
},
},
}
awards := Awards{}
if form.Accept {
redis.SetRelationship(user.Id, []string{form.Sender}, models.RelFriend, true)
event.Save()
redis.PubMsg(models.EventSystem, form.Sender, event.Bytes())
awards.Wealth = 1 * models.Satoshi
GiveAwards(user, awards, redis)
}
redis.SetHeartRecv(user.Id, false)
writeResponse(r.RequestURI, w, map[string]interface{}{"ExpEffect": awards}, nil)
}
示例2: sendHeartHandler
func sendHeartHandler(r *http.Request, w http.ResponseWriter,
redis *models.RedisLogger, user *models.Account, p Parameter) {
form := p.(sendHeartForm)
receivers := redis.HeartReceivers(user.Id)
if len(receivers) == 0 {
writeResponse(r.RequestURI, w, nil, nil)
}
var target string
for _, recv := range receivers {
if recv != user.Id {
target = recv
break
}
}
// ws push
event := &models.Event{
Type: models.EventSystem,
Time: time.Now().Unix(),
Data: models.EventData{
Type: models.EventSendHeart,
Id: user.Id,
From: user.Id,
To: target,
Body: []models.MsgBody{
{Type: "record_id", Content: form.Record},
{Type: "userid", Content: user.Id},
},
},
}
if len(target) > 0 {
event.Save()
redis.PubMsg(models.EventSystem, target, event.Bytes())
redis.LogHeartSend(user.Id)
redis.SetHeartRecv(target, true)
}
writeResponse(r.RequestURI, w, nil, nil)
}