當前位置: 首頁>>代碼示例>>Golang>>正文


Golang RedisLogger.SetHeartRecv方法代碼示例

本文整理匯總了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)
}
開發者ID:shevilangle,項目名稱:sports,代碼行數:31,代碼來源:account.go

示例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)
}
開發者ID:shevilangle,項目名稱:sports,代碼行數:42,代碼來源:account.go


注:本文中的github.com/ginuerzh/sports/models.RedisLogger.SetHeartRecv方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。