Skip to content

cupen/game-anti-addiction

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

Go SDK of china national video game anti-addiction system.

Status

alpha(used in production)

TestSuite

testcase01~08(Chinese)

Usages

  • idcard check

    c := auth.NewClient(appId, bizId, secretKey)
    req := idcard.CheckRequest{IDNum:"xx", Name:"xx", AI:"xx"}
    resp, err := req.Do(c)
  • idcard query

    req := idcard.QueryRequest{AI:"xx"}
    resp, err := req.Do(c)
  • behavior upload

    events := []behavior.LoginOutEvent{{}, {}} 
    req := behavior.LoginOutRequest{Collection: events}
    resp, err := req.Do(c)
  • message queue and producer, consumer

    c := auth.NewClient(appId, bizId, secretKey)
    queue, err := redisstream.New(redisUrl, "behavior")
    
    // producer
    obj := behavior.NewLogin(...) // or NewLogout(...)
    data, _ := json.Marshal(obj)
    err = queue.Write(data)
    
    // consumer
    c := auth.NewClient(appId, bizId, secretKey)
    consumerFunc := behavior.ConsumerFunc(c, 128, 100)
    consumer := consumer.New(queue, consumerFunc)
    consumer.Start()
    
    // consumer(manually)
    msgList, err := queue.Read(1024, 1*time.Second)
    reqList, err := behavior.DecodeLoginOutRequest(msgList, 128)
    for _, req := range reqList {
        resp, err := req.Do(c)
    }

More Usages

out-of-box way
c := auth.NewClient(appId, bizId, secretKey)
gaa, err := outofbox.New(c, redisUrl)
gaa.Start(nil)
gaa.PushBehavior(xxx)
gaa.PushQueryRequest(xxx)

License

MIT License

About video game anti-addiction (Chinese)

About

go sdk for https://wlc.nppa.gov.cn/ (电子游戏防沉迷系统)。

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages