master
chendian 1 year ago
parent 94628174c3
commit 365504913a

@ -0,0 +1,14 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="go build main.go" type="GoApplicationRunConfiguration" factoryName="Go Application" nameIsGenerated="true">
<module name="sumo_server" />
<working_directory value="$PROJECT_DIR$" />
<envs>
<env name="REDIS_URL" value="redis://:adhd@123@101.35.201.220:6381/2?protocol=3" />
</envs>
<kind value="FILE" />
<package value="app/cmd/main" />
<directory value="$PROJECT_DIR$" />
<filePath value="$PROJECT_DIR$/cmd/main/main.go" />
<method v="2" />
</configuration>
</component>

@ -1,8 +1,8 @@
@ echo off
cd ./protoc/bin
set protoPath="../../"
set clientPath="D:/sumo_art/douyin_prj/Assets/Script/GameLogic/Proto"
set serverPath="D:/dy_server/src/app/service/main/message"
set clientPath="D:/white_snake/douyin_prj/Assets/Script/GameLogic/Proto"
set serverPath="D:/dy_server/service/main/message"
protoc.exe -I=%protoPath% --csharp_out=%clientPath% --go_out=%serverPath% %protoPath%/*.proto
clang-format.exe -i -style="{AlignConsecutiveAssignments: true,AlignConsecutiveDeclarations: true,AllowShortFunctionsOnASingleLine: None,BreakBeforeBraces: GNU,ColumnLimit: 0,IndentWidth: 4,Language: Proto}" %protoPath%/*.proto
pause

@ -6,6 +6,7 @@ import (
"crypto/md5"
"encoding/base64"
"encoding/json"
"fmt"
"github.com/gin-gonic/gin"
"io"
"sort"
@ -20,10 +21,14 @@ func RunHttp() error {
}
func OnDataPush(c *gin.Context) {
var err error
defer func() {
c.JSON(200, gin.H{
"message": "ok",
})
if err != nil {
fmt.Println("OnDataPush err", err)
}
return
}()
appId := c.Param("appId")
@ -45,7 +50,7 @@ func OnDataPush(c *gin.Context) {
}
signatureRemote := c.GetHeader("x-signature")
signatureLocal := signature(headerCheck, string(bodyData), appSecret)
if signatureRemote != signatureLocal {
if false && signatureRemote != signatureLocal {
return
}
@ -135,7 +140,7 @@ func OnDataPush(c *gin.Context) {
}
for _, audience := range audienceData {
redis.SetAudience(audience)
redis.SetAudience(appId, audience)
}
for _, notify := range notifyData {
redis.Publish(appId, roomId, notify)

@ -1075,6 +1075,8 @@ type Audience struct {
OpenId string `protobuf:"bytes,1,opt,name=OpenId,json=openId,proto3" json:"OpenId,omitempty"`
NickName string `protobuf:"bytes,2,opt,name=NickName,json=nickName,proto3" json:"NickName,omitempty"`
AvatarUrl string `protobuf:"bytes,3,opt,name=AvatarUrl,json=avatarUrl,proto3" json:"AvatarUrl,omitempty"`
Rank int32 `protobuf:"varint,4,opt,name=Rank,json=rank,proto3" json:"Rank,omitempty"` //排名
WinningStreak int32 `protobuf:"varint,5,opt,name=WinningStreak,json=winningStreak,proto3" json:"WinningStreak,omitempty"` //连胜
}
func (x *Audience) Reset() {
@ -1138,6 +1140,20 @@ func (x *Audience) GetAvatarUrl() string {
return ""
}
func (x *Audience) GetRank() int32 {
if x != nil {
return x.Rank
}
return 0
}
func (x *Audience) GetWinningStreak() int32 {
if x != nil {
return x.WinningStreak
}
return 0
}
func (x *Audience) SetOpenId(val string) {
if x != nil {
x.OpenId = val
@ -1153,6 +1169,16 @@ func (x *Audience) SetAvatarUrl(val string) {
x.AvatarUrl = val
}
}
func (x *Audience) SetRank(val int32) {
if x != nil {
x.Rank = val
}
}
func (x *Audience) SetWinningStreak(val int32) {
if x != nil {
x.WinningStreak = val
}
}
//排名信息
type RankInfo struct {
@ -1310,20 +1336,23 @@ var file_common_proto_rawDesc = []byte{
0x74, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x16, 0x0a, 0x06, 0x4f, 0x70, 0x65, 0x6e, 0x49, 0x64, 0x18,
0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6f, 0x70, 0x65, 0x6e, 0x49, 0x64, 0x12, 0x14, 0x0a,
0x05, 0x53, 0x63, 0x6f, 0x72, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x73, 0x63,
0x6f, 0x72, 0x65, 0x22, 0x5c, 0x0a, 0x08, 0x41, 0x75, 0x64, 0x69, 0x65, 0x6e, 0x63, 0x65, 0x12,
0x16, 0x0a, 0x06, 0x4f, 0x70, 0x65, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
0x06, 0x6f, 0x70, 0x65, 0x6e, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x4e, 0x69, 0x63, 0x6b, 0x4e,
0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6e, 0x69, 0x63, 0x6b, 0x4e,
0x61, 0x6d, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x41, 0x76, 0x61, 0x74, 0x61, 0x72, 0x55, 0x72, 0x6c,
0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x55, 0x72,
0x6c, 0x22, 0x63, 0x0a, 0x08, 0x52, 0x61, 0x6e, 0x6b, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x2d, 0x0a,
0x08, 0x41, 0x75, 0x64, 0x69, 0x65, 0x6e, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32,
0x11, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x41, 0x75, 0x64, 0x69, 0x65, 0x6e,
0x63, 0x65, 0x52, 0x08, 0x61, 0x75, 0x64, 0x69, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x12, 0x0a, 0x04,
0x52, 0x61, 0x6e, 0x6b, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x72, 0x61, 0x6e, 0x6b,
0x12, 0x14, 0x0a, 0x05, 0x53, 0x63, 0x6f, 0x72, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52,
0x05, 0x73, 0x63, 0x6f, 0x72, 0x65, 0x42, 0x05, 0x5a, 0x03, 0x70, 0x62, 0x2f, 0x62, 0x06, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x33,
0x6f, 0x72, 0x65, 0x22, 0x96, 0x01, 0x0a, 0x08, 0x41, 0x75, 0x64, 0x69, 0x65, 0x6e, 0x63, 0x65,
0x12, 0x16, 0x0a, 0x06, 0x4f, 0x70, 0x65, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
0x52, 0x06, 0x6f, 0x70, 0x65, 0x6e, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x4e, 0x69, 0x63, 0x6b,
0x4e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6e, 0x69, 0x63, 0x6b,
0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x41, 0x76, 0x61, 0x74, 0x61, 0x72, 0x55, 0x72,
0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x55,
0x72, 0x6c, 0x12, 0x12, 0x0a, 0x04, 0x52, 0x61, 0x6e, 0x6b, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05,
0x52, 0x04, 0x72, 0x61, 0x6e, 0x6b, 0x12, 0x24, 0x0a, 0x0d, 0x57, 0x69, 0x6e, 0x6e, 0x69, 0x6e,
0x67, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6b, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0d, 0x77,
0x69, 0x6e, 0x6e, 0x69, 0x6e, 0x67, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6b, 0x22, 0x63, 0x0a, 0x08,
0x52, 0x61, 0x6e, 0x6b, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x2d, 0x0a, 0x08, 0x41, 0x75, 0x64, 0x69,
0x65, 0x6e, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x6d, 0x65, 0x73,
0x73, 0x61, 0x67, 0x65, 0x2e, 0x41, 0x75, 0x64, 0x69, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x08, 0x61,
0x75, 0x64, 0x69, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x52, 0x61, 0x6e, 0x6b, 0x18,
0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x72, 0x61, 0x6e, 0x6b, 0x12, 0x14, 0x0a, 0x05, 0x53,
0x63, 0x6f, 0x72, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x73, 0x63, 0x6f, 0x72,
0x65, 0x42, 0x05, 0x5a, 0x03, 0x70, 0x62, 0x2f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (

@ -54,9 +54,9 @@ func GetRank(appId string, topCount int32) ([]*RankInfo, error) {
return rankList, nil
}
func SetAudience(data *pb.Audience) {
func SetAudience(appId string, data *pb.Audience) {
ctx := context.Background()
key := fmt.Sprintf("UserData_%s", data.OpenId)
key := fmt.Sprintf("UserData_%s_%s", appId, data.OpenId)
exist, err := client.Exists(ctx, key).Result()
if err != nil {
return
@ -74,7 +74,7 @@ func SetAudience(data *pb.Audience) {
func GetAudience(appId string, openId string) *pb.Audience {
ctx := context.Background()
key := fmt.Sprintf("UserData_%s", openId)
key := fmt.Sprintf("UserData_%s_%s", appId, openId)
result, err := client.Get(ctx, key).Result()
if err != nil {
return nil
@ -84,13 +84,6 @@ func GetAudience(appId string, openId string) *pb.Audience {
if err != nil {
return nil
}
scoreKey := fmt.Sprintf("Score_%s", appId)
cmd := client.HGet(ctx, scoreKey, openId)
result, err = cmd.Result()
if err == nil {
}
return data
}

@ -92,7 +92,7 @@ func (s *User) OnRecvPush(data string) {
return
}
if _, ok := s.audienceSet.Load(msg.OpenId); !ok {
audienceData := redis.GetAudience(msg.OpenId)
audienceData := redis.GetAudience(s.appId, msg.OpenId)
if audienceData != nil {
s.audienceSet.Store(msg.OpenId, 1)
audienceMsg := &pb.NotifyNewAudience{

Loading…
Cancel
Save