- 游戏来源常量/按目录特征识别(云更新/网维大师/易乐游)/RunAppRecord 上报框架 - 网吧业务专用包, 附测试、examples/cafegame 例程与包 README
64 lines
1.6 KiB
Go
64 lines
1.6 KiB
Go
//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
|
|
}
|