forked from Philipp15b/go-steam
-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.go
106 lines (80 loc) · 2.28 KB
/
app.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
package steam
import (
"fmt"
"time"
"github.com/Flo4604/go-steam/v5/protocol"
"github.com/Flo4604/go-steam/v5/protocol/protobuf"
"github.com/Flo4604/go-steam/v5/protocol/steamlang"
"google.golang.org/protobuf/proto"
)
type App struct {
client *Client
options *AppOptions
latestChangeNumber uint32
}
type AppOptions struct {
EnablePicsCache bool
ChangelistUpdateInterval int // in seconds
PicsCacheAll bool
}
func (a *App) HandlePacket(packet *protocol.Packet) {
switch packet.EMsg {
// log all events
case steamlang.EMsg_ClientPICSChangesSinceResponse:
a.handlePicsChangesSinceResponse(packet)
case steamlang.EMsg_ClientPICSProductInfoResponse:
a.handlePicsProductInfoResponse(packet)
}
}
func (a *App) getChangeListUpdate() {
if !a.options.EnablePicsCache || a.options.ChangelistUpdateInterval <= 0 {
println("PICS cache is disabled or update interval is 0, not updating changelist")
return
}
ticker := time.NewTicker(time.Duration(a.options.ChangelistUpdateInterval) * time.Second)
quit := make(chan struct{})
go func() {
for {
select {
case <-ticker.C:
println("Updating changelist")
data := new(protobuf.CMsgClientPICSChangesSinceRequest)
data.SendAppInfoChanges = proto.Bool(true)
data.SendPackageInfoChanges = proto.Bool(true)
data.SinceChangeNumber = proto.Uint32(20785330)
a.client.Write(protocol.NewClientMsgProtobuf(steamlang.EMsg_ClientPICSChangesSinceRequest, data))
case <-quit:
ticker.Stop()
return
}
}
}()
}
func (a *App) handlePicsChangesSinceResponse(packet *protocol.Packet) {
if !packet.IsProto {
a.client.Fatalf("Got non-proto picsChangesSince response!")
return
}
body := new(protobuf.CMsgClientPICSChangesSinceResponse)
msg := packet.ReadProtoMsg(body)
// dump the msg
fmt.Printf("handlePicsChangesSinceResponse %+v\n", msg)
}
func (a *App) handlePicsProductInfoResponse(packet *protocol.Packet) {
if !packet.IsProto {
a.client.Fatalf("Got non-proto picsProductInfo response!")
return
}
}
func (a *App) handlePicsAccessTokenResponse(packet *protocol.Packet) {
if !packet.IsProto {
a.client.Fatalf("Got non-proto picsAccessToken response!")
return
}
}
func (a *App) GetAppInfo(appId uint32) {
}
func (a *App) GetAppChangesSince(changedId uint32) {
}
func (a *App) GetProductInfo() {
}