Example of Online Operation

Assuming a shared space which is implementing a 2x2 colorgrid. There is a single data object named "grid", and the default data is:

{
  "0": "ffffff",
  "1": "ffffff",
  "2": "ffffff",
  "3": "ffffff"
}

The owner will store an initial state packet that matches the following:

{
    "sequence": 0,
    "apply_to": null,
    "mimetype": "application/json",
    "name": "grid",
    "op": "add",
    "path": "/",
    "data": {
      "0": "ffffff",
      "1": "ffffff",
      "2": "ffffff",
      "3": "ffffff"
    }
}

For this example, the member wishes to update space with id "2" to the color "ff0000". The operation sent from the member to the owner is created as:

{
    "mimetype": "application/json",
    "name": "grid",
    "op": "replace",
    "path": "/2",
    "data": "ff0000",
    "apply_to": 0
}

The member making this change should not consider it accepted or committed at this point. The owner will receive this operation, and will store this packet in the list. The entire list of operations stored by the owner now looks like this:

{
  "max_sequence": 1,
  "operations": [
    {
      "sequence": 0,
      "mimetype": "application/json",
      "name": "grid",
      "op": "add",
      "path": "/",
      "data": {
        "0": "ffffff",
        "1": "ffffff",  
        "2": "ffffff",
        "3": "ffffff"
      },
      {
        "sequence": 1,
        "mimetype": "application/json",
        "name": "grid",
        "op": "replace",
        "path": "/2",
        "data": "ff0000"
      }
  ]
}

At this point, the owner should deliver this operation to all members connected to the shared space.