The inventory's product list (test.showInventory) gets the community products the person has: local packs, and hub products in their library. Hiding one is answered by the proxy (and removes a hub product from the library). When the library changes, the client is told to load its inventory again, with the server event IMVU sends after a purchase. A product whose revision or info changes gets a new local ID, since the client keeps product info for good; names lose characters the client's pages could take as HTML. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
c281fb572c
commit
ca7a86ce89
8 files changed
+225
-5
No files matched your search
@@ -31,6 +31,7 @@ type room struct {
|
||||
userIDs map[int64]string // user -> the gateway's user_id for them, as last seen
|
||||
missing map[string]bool // products others wear that aren't in the packs (logged once)
|
||||
last map[string][]hub.Avatar // chat -> what the hub last said about the others in it
|
||||
users map[*proxy.IMQConn]string // each connection's user queue ("/user/<id>")
|
||||
}
|
||||
|
||||
func (r *room) init() {
|
||||
@@ -41,6 +42,7 @@ func (r *room) init() {
|
||||
r.userIDs = map[int64]string{}
|
||||
r.missing = map[string]bool{}
|
||||
r.last = map[string][]hub.Avatar{}
|
||||
r.users = map[*proxy.IMQConn]string{}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,6 +72,9 @@ func (p *Products) Subscribed(c *proxy.IMQConn, queues []string) {
|
||||
var joined []string
|
||||
var rooms []string
|
||||
for _, q := range queues {
|
||||
if strings.HasPrefix(q, "/user/") {
|
||||
p.room.users[c] = q
|
||||
}
|
||||
chat := chatOf(q)
|
||||
if chat == "" {
|
||||
continue
|
||||
@@ -124,6 +129,7 @@ func (p *Products) Closed(c *proxy.IMQConn) {
|
||||
p.Unsubscribed(c, queues)
|
||||
p.roomMu.Lock()
|
||||
delete(p.room.subs, c)
|
||||
delete(p.room.users, c)
|
||||
p.roomMu.Unlock()
|
||||
}
|
||||
|
||||
@@ -358,3 +364,20 @@ func (p *Products) interceptParticipant(x *proxy.Exchange) error {
|
||||
x.Body = body
|
||||
return nil
|
||||
}
|
||||
|
||||
// RefreshInventory has the client load its inventory again (after the library changed), with the server event
|
||||
// IMVU sends after a purchase: "refreshInventory {}" on the user queue's web_msg mount.
|
||||
func (p *Products) RefreshInventory() {
|
||||
p.roomMu.Lock()
|
||||
p.room.init()
|
||||
users := make(map[*proxy.IMQConn]string, len(p.room.users))
|
||||
for c, q := range p.room.users {
|
||||
users[c] = q
|
||||
}
|
||||
p.roomMu.Unlock()
|
||||
for c, q := range users {
|
||||
if err := c.Deliver(imq.Delivered{UserID: "0", Queue: q, Mount: "web_msg", Message: []byte("refreshInventory {}")}); err != nil {
|
||||
p.logf("products: refreshing the inventory: %v", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user