feat(cafegame): 自 go-hua 迁入网咖游戏识别与运行记录框架
- 游戏来源常量/按目录特征识别(云更新/网维大师/易乐游)/RunAppRecord 上报框架 - 网吧业务专用包, 附测试、examples/cafegame 例程与包 README
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
//go:build windows
|
||||
|
||||
package cafegame
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"sync"
|
||||
)
|
||||
|
||||
var mux sync.Mutex
|
||||
var appIgnoreProcess []AppIgnoreProcess
|
||||
|
||||
// AppIgnoreProcess 需要忽略的游戏进程配置(不参与监控统计)
|
||||
type AppIgnoreProcess struct {
|
||||
AppId int `json:"appId" gorm:"column:app_id"`
|
||||
AppName string `json:"appName" gorm:"column:app_name"`
|
||||
AppSource int `json:"appSource" gorm:"column:app_source"`
|
||||
AppGuid string `json:"appGuid" gorm:"column:app_guid"`
|
||||
ProcessName []string `json:"processName" gorm:"column:process_name"`
|
||||
Status int `json:"status" gorm:"column:status"`
|
||||
}
|
||||
|
||||
func init() {
|
||||
mux.Lock()
|
||||
appIgnoreProcess = make([]AppIgnoreProcess, 0)
|
||||
mux.Unlock()
|
||||
}
|
||||
|
||||
// AddIgnoreProcessItem 添加单条忽略配置
|
||||
func AddIgnoreProcessItem(item AppIgnoreProcess) {
|
||||
mux.Lock()
|
||||
defer mux.Unlock()
|
||||
appIgnoreProcess = append(appIgnoreProcess, item)
|
||||
}
|
||||
|
||||
// AddIgnoreProcessList 批量添加忽略配置
|
||||
func AddIgnoreProcessList(list []AppIgnoreProcess) {
|
||||
mux.Lock()
|
||||
defer mux.Unlock()
|
||||
appIgnoreProcess = append(appIgnoreProcess, list...)
|
||||
}
|
||||
|
||||
// checkGameProcessIsIgnore 判断指定游戏的进程名是否在忽略列表中(大小写不敏感)
|
||||
func checkGameProcessIsIgnore(appId int, processName string) bool {
|
||||
if appId == 0 || processName == "" {
|
||||
return false
|
||||
}
|
||||
|
||||
mux.Lock()
|
||||
defer mux.Unlock()
|
||||
|
||||
for _, game := range appIgnoreProcess {
|
||||
if appId == game.AppId && appId != 0 {
|
||||
for _, s := range game.ProcessName {
|
||||
if strings.ToLower(s) == strings.ToLower(processName) && processName != "" {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
Reference in New Issue
Block a user