forked from paralin/go-dota2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
client_cache.go
70 lines (56 loc) · 2.03 KB
/
client_cache.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
package dota2
import (
"github.com/faceit/go-steam/protocol/gamecoordinator"
gcsdkm "github.com/paralin/go-dota2/protocol"
gcsm "github.com/paralin/go-dota2/protocol"
)
// RequestCacheSubscriptionRefresh requests a subscription refresh for a specific cache ID.
func (d *Dota2) RequestCacheSubscriptionRefresh(ownerSoid *gcsdkm.CMsgSOIDOwner) {
d.write(uint32(gcsm.ESOMsg_k_ESOMsg_CacheSubscriptionRefresh), &gcsdkm.CMsgSOCacheSubscriptionRefresh{
OwnerSoid: ownerSoid,
})
}
// handleCacheSubscribed handles a CacheSubscribed packet.
func (d *Dota2) handleCacheSubscribed(packet *gamecoordinator.GCPacket) error {
sub := &gcsdkm.CMsgSOCacheSubscribed{}
if err := d.unmarshalBody(packet, sub); err != nil {
return err
}
if err := d.cache.HandleSubscribed(sub); err != nil {
d.le.WithError(err).Debug("unhandled cache issue (ignore)")
}
return nil
}
// handleCacheUnsubscribed handles a CacheUnsubscribed packet.
func (d *Dota2) handleCacheUnsubscribed(packet *gamecoordinator.GCPacket) error {
sub := &gcsdkm.CMsgSOCacheUnsubscribed{}
if err := d.unmarshalBody(packet, sub); err != nil {
return err
}
if err := d.cache.HandleUnsubscribed(sub); err != nil {
d.le.WithError(err).Debug("unhandled cache issue (ignore)")
}
return nil
}
// handleCacheUpdateMultiple handles when one or more object(s) in a cache is/are updated.
func (d *Dota2) handleCacheUpdateMultiple(packet *gamecoordinator.GCPacket) error {
sub := &gcsdkm.CMsgSOMultipleObjects{}
if err := d.unmarshalBody(packet, sub); err != nil {
return err
}
if err := d.cache.HandleUpdateMultiple(sub); err != nil {
d.le.WithError(err).Debug("unhandled cache issue (ignore)")
}
return nil
}
// handleCacheDestroy handles when an object in a cache is destroyed.
func (d *Dota2) handleCacheDestroy(packet *gamecoordinator.GCPacket) error {
sub := &gcsdkm.CMsgSOSingleObject{}
if err := d.unmarshalBody(packet, sub); err != nil {
return err
}
if err := d.cache.HandleDestroy(sub); err != nil {
d.le.WithError(err).Debug("unhandled cache issue (ignore)")
}
return nil
}