Likes
packets4 packets
Likes (resourceArray.ResourceArrayXtCommManager): the heart under a masterpiece in its preview (gui.MasterpiecePreview) and the one on a player's wall (playerWall.PlayerWallGui). The server keeps a list of who liked each resource, named by a type and an id; the client asks how many there are and whether the player is among them, and adds the player to it.
The client keeps one callback for each kind of request (_resourceArrayGetCallback, _resourceArrayPutCallback), and the answers do not name what they answer, so they are matched to their requests by order.
Hearing and sending packets
What the game sends is heard on phantom.packets.client, and what the server sends on phantom.packets.server. watch hears a packet after it has gone through; on hears it first and may change or drop it; send sends one to that end. See Packets.
Overview
| Packet | Command | Way | What it is |
|---|---|---|---|
ResourceArrayGetRequest | crg | game → server | The player asks how many have liked a masterpiece or a wall. |
ResourceArrayGet | crg | server → game | The server says how many have liked a masterpiece or a wall. |
ResourceArrayPutRequest | crp | game → server | The player likes a masterpiece or a wall. |
ResourceArrayPut | crp | server → game | The server says whether a like was taken. |
ResourceArrayGetRequest
Asks how many have liked something, and whether the player has (ResourceArrayXtCommManager.sendResourceArrayGetRequest(type, id, report, callback)):
%xt%o%crg%<room>%<type>%<id>%<myUUID>%<report>%
report is written report when set and empty when not. Every caller in the client sets it (MasterpiecePreview and PlayerWallGui.setupLikes); what the server does differently without it is not known.
Fields
| Field | Type | |
|---|---|---|
resourceType | string | What kind of thing it is (RESOURCE_TYPE): masterpiece or jammerwall. |
resourceId | string | Which one: a masterpiece's uniqueImageId, or a wall owner's uuid. |
userUuid | string | The player asking, by their account's uuid (userInfo.myUUID). |
report | boolean | Whether the request carries report, as every one the client makes does. |
room | number | The room the message was sent in, as the SmartFox room id; -1 when it names none. |
Example
// Each time the game sends it to the server, after it has gone through.
const stop = phantom.packets.client.watch(packets.ResourceArrayGetRequest, (packet) => {
console.log(packet.resourceType, packet.resourceId, packet.userUuid);
});ResourceArrayGet
How many have liked something, and whether the player has (ResourceArrayXtCommManager.handleXtReply, which hands them to the request's callback):
%xt%crg%<room>%<ok>%<liked>%<count>%
ok and liked are 1 when set. A refusal still carries the other two, which the client does not read (MasterpiecePreview.onResourceArrayGet shows 0).
Fields
| Field | Type | |
|---|---|---|
ok | boolean | Whether the server could answer: 1. |
liked | boolean | Whether the player has already liked it: 1. The client then shows the heart pressed. |
count | number | How many have liked it; 0 when the answer carries no count. |
extra | string[] | Whatever follows, as it came. |
room | number | The room the message was sent in, as the SmartFox room id; -1 when it names none. |
Example
// Each time the server sends it to the game, after it has gone through.
const stop = phantom.packets.server.watch(packets.ResourceArrayGet, (packet) => {
console.log(packet.ok, packet.liked, packet.count);
});ResourceArrayPutRequest
Likes something (ResourceArrayXtCommManager.sendResourceArrayPutRequest), as pressing the heart does:
%xt%o%crp%<room>%jammerwall%<ownerUUID>%<myUUID>% %xt%o%crp%<room>%masterpiece%<uniqueImageId>%<myUUID>%<detail>%<version>,<creatorUUID>,<creatorDbId>%
A masterpiece also says who drew it, in one field the client builds as an array and the connection writes joined by commas; the client sends nothing for a masterpiece whose creator's account id is not above 0. detail is always empty from the client, and what it is for is not known.
Fields
| Field | Type | |
|---|---|---|
resourceType | string | What kind of thing it is (RESOURCE_TYPE): masterpiece or jammerwall. |
resourceId | string | Which one: a masterpiece's uniqueImageId, or a wall owner's uuid. |
userUuid | string | The player liking it, by their account's uuid (userInfo.myUUID). |
detail | string | null | Sent for a masterpiece only, always empty from the client. Null for a wall. |
creator | ResourceArrayCreator | null | Who drew a masterpiece, and which look it is drawn on. Null for a wall. |
extra | string[] | Whatever follows, as it came. |
room | number | The room the message was sent in, as the SmartFox room id; -1 when it names none. |
Example
// Each time the game sends it to the server, after it has gone through.
const stop = phantom.packets.client.watch(packets.ResourceArrayPutRequest, (packet) => {
console.log(packet.resourceType, packet.resourceId, packet.userUuid);
});ResourceArrayPut
Whether the like was taken (ResourceArrayXtCommManager.handleXtReply, then the request's callback, which presses the heart and adds one to its count):
%xt%crp%<room>%<ok>%
Fields
| Field | Type | |
|---|---|---|
ok | boolean | Whether the like was taken: 1. |
extra | string[] | Whatever follows, as it came. |
room | number | The room the message was sent in, as the SmartFox room id; -1 when it names none. |
Example
// Each time the server sends it to the game, after it has gone through.
const stop = phantom.packets.server.watch(packets.ResourceArrayPut, (packet) => {
console.log(packet.ok, packet.extra);
});