FG Spreadshirt Swag
Page 1 of 2 12 Last
  1. #1

    Database nodes and connected clients

    What exactly is the criteria for connected clients to access database nodes. It most cases, the host needs to have updated it with the client connected just for it to be visible. Absent of an update the client can't access it. Sometimes the clients never get access to it despite the node being public.

    This is handled rather haphazardly.

  2. #2
    Quote Originally Posted by Ken L View Post
    What exactly is the criteria for connected clients to access database nodes. It most cases, the host needs to have updated it with the client connected just for it to be visible. Absent of an update the client can't access it. Sometimes the clients never get access to it despite the node being public.

    This is handled rather haphazardly.
    Not sure if this will help but it's some code I used to give users access to nodes so they could edit effects as themselves. I've since re-done how I handled this so it's no longer necessary but it sounds similar to what you're trying to do. Maybe this example will help?

    Code:
    --
    --
    -- Access to nodes managed for certain places here
    --
    -- Right now this mainly deals with CT nodes so that players can apply effects
    -- that are on items or other areas --celestian
    --
    
    function onInit()
        User.onIdentityActivation = onIdentityActivation;
    end
    
    function onIdentityActivation(sIdentity, sUser, bActivated)
    -- Debug.console("manager_Access_adnd.lua","onIdentityActivation","sIdentity",sIdentity);
    -- Debug.console("manager_Access_adnd.lua","onIdentityActivation","sUser",sUser);
    -- Debug.console("manager_Access_adnd.lua","onIdentityActivation","bActivated",bActivated);
    -- Debug.console("manager_Access_adnd.lua","onIdentityActivation","User.getAllActiveIdentities()",User.getAllActiveIdentities());
    -- Debug.console("manager_Access_adnd.lua","onIdentityActivation","User.getAllActiveIdentities()",User.getAllActiveIdentities());
      if bActivated then
        -- give access to CT node it character if exists
            local nodeCT = CombatManager.getCTFromNode("charsheet." .. sIdentity);
            if nodeCT and sUser ~= "" then
           local owner = nodeCT.getOwner();
           if owner then
             nodeCT.removeHolder(owner);
           end
                DB.setOwner(nodeCT, sUser);
            end
      else
        -- remove access to CT node if character exists
            local nodeCT = CombatManager.getCTFromNode("charsheet." .. sIdentity);
            if nodeCT and sUser ~= "" then
          local owner = nodeCT.getOwner();
          if owner then
            nodeCT.removeHolder(owner);
          end
            end
        end
    end
    
    -- flip through active users and their active identities and if they match
    -- the nodeCT we just added then give them ownership
    function manageCTOwners(nodeCT)
        for _,vUser in ipairs(User.getActiveUsers()) do
            for _,vIdentity in ipairs(User.getActiveIdentities(vUser)) do
                local _, sRecord = DB.getValue(nodeCT, "link", "", "");
                 if (sRecord == ("charsheet." .. vIdentity)) then
                    DB.setOwner(nodeCT, vUser);
                end
            end
        end
    end
    I can't find it but I think I also had to cope with players disconnecting then reconnecting.
    ---
    Fantasy Grounds AD&D Reference Bundle, AD&D Adventure Bundle 1, AD&D Adventure Bundle 2
    Documentation for AD&D 2E ruleset.
    Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)
    Note: Please do not message me directly on this site, post in the forums or ping me in FG's discord.

  3. #3
    Adding holders is a way to force accessibility, and is in general more reliable than setting the node as public. In the area of interest to me however, I don't want to grant ownership, and stringing up a list of holders is a bit unnecessary for juggling.

    The main issue is that FG doesn't want to save the <public/> variable which in turn doesn't transmit to clients. Even worse it won't save it to the db.xml for the next session. This however isn't a reliable failure, and using 'list' formats where the base node is public as opposed to individual children helps but is also not guaranteed to persist.

  4. #4

    Join Date
    Apr 2008
    Location
    Virginia Beach
    Posts
    3,096
    Rather than start a thread, I thought I would piggy back on this as my question is related. Now that moon wizard is back from leave maybe he will reply to Ken.

    My question is what happens to nodes created on a client instance of FG? I would assume the owner is automatically set to the user of the client instance?

    And I would assume that the original new node contents and any changes to it are sent back to the host for permanent recording in campaign database?

  5. #5
    I didn't see a question from Ken above, and I'm not seeing that issue. I figured Ken would smack me with a clear failure case, if he needed that looked at.

    For your questions,
    * DB nodes can only be automatically created on the client as children of nodes they already own. Any ownership/viewership information is inherited from the parent node.
    * When a database node is created on the client, the information is sent to the host. If the node is also viewable by others, then the update is propagated to the other clients.
    * There are some cases where non-value database nodes (i.e. empty lists, base records without values) don't get propagated until a value node is added/updated.
    * There is a special API call to request a new child node to be created and assigned ownership to the client. (currently only used for creating characters from the client)

    Regards,
    JPG

  6. #6

    Join Date
    Apr 2008
    Location
    Virginia Beach
    Posts
    3,096
    Thanks, jpg. I will look at client db to see what standard nodes will always be available on a client (or use the special api)

  7. #7

    Join Date
    Apr 2008
    Location
    Virginia Beach
    Posts
    3,096
    Rocking out and I cannot remember nor find where the db.xml is stored when you use localhost to log on to a gm's campaign?

  8. #8
    There is no db.xml for the layer instance, just a encrypted cache file of the files shared by the GM.

    JPG

  9. #9

    Join Date
    Apr 2008
    Location
    Virginia Beach
    Posts
    3,096
    Thanks, MW. Now, the problem I am having is that I am trying to install an owned node update handler in the client instance, but the cache doesn't have the node at onDesktopInit time for the client. Is there another event I cannot figure out where the local cache will have the owned node in it? I know the node exists because I installed a slash handler that lets me display the node's name, and that slash handler shows the node's name. However, the code in onDesktopInit shows nil for the node name.

  10. #10

    Join Date
    Apr 2008
    Location
    Virginia Beach
    Posts
    3,096
    Nvm. I figured out an alternative (no rocket science - I just don’t set up the resources until the demand arises. By then, all initialization is done)

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
5E Character Create Playlist

Log in

Log in