How To Update Remote Room Properties

Because Diarkis is decentralized, you may need to operate on rooms that are not on the same server process. Here, we explain how to manipulate room properties that are not on the same server process.

By using Diarkis’ internal communication mechanism mesh, you can read and/or update remote room properties.

Sending Update Command To The Server Node Where The Target Room Is

property := room.GetProperty(roomID, "counter")
if property == nil {
    // Handle error
capsule := datacapsule.NewCapsule()
err := capsule.Import(property)
if err != nil {
    // Handle error
counter := capsule.GetAsInt("counter")

Update Logic On A Remote Server Node

// This sets up handleRemoteRoomPropUpdate function to be invoked when mesh.SendRequest sends

// The command message as shown above
mesh.Command(cmdID, handleRemoteRoomPropUpdate)

func handleRemoteRoomPropUpdate(req map[string]interface{}) (error, map[string]interface{}) {
    roomID := mesh.GetString(req, "roomID")
    var err error
    _ := room.UpdateProperties(roomID, func(props map[string]interface{}) bool {
            if _, ok := props["booked"]; !ok {
                    props["booked"] = true
                    // Booked the room successfully
                    return true
            // The room has already been booked...
            err = errors.New("Room has already been booked")
            return false
      res := make(map[string]interface{})
      return res, err

Last updated