CharlesHolbrow / synk

support syncing data with browser
0 stars 0 forks source link

subscription keys sometimes included in json messages twice #5

Open CharlesHolbrow opened 7 years ago

CharlesHolbrow commented 7 years ago

We currently support two ways of generating SKey Getters/Setters.

  1. Add a SKey string member to the object. Pagen will create GetPrevSKey, GetSKey for us (both of which are required to satisfy the Object interface)
  2. Manually write GetPrevSKey and GetSKey. These must call GetPrev<X> and Get<X> so that the Changed works as intended.

SKey and PSKey members are added at the top level to the JSON objects sent to Clients. This means that IF an object includes an SKey member, The SKey will actually be sent to clients twice inside the same object like this

{
method: "addObj"
state:
  {
    "subKey": "eternal:main", // identical
    "number": 79,
    "velocity": 0
  },
key: "n:7",
sKey: "eternal:main" // identical
}

Consider these options:

  1. We could decide that this is not a problem. However, this is risky, because it may cause bugs if we accidentaly write javascript that depends on the inner subKey value
  2. We could modify pagen so it adds json:,omit to the subKey diff member. (verify syntax)