Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
    • Switch to GitLab Next
  • Sign in / Register
Foundry Virtual Tabletop
Foundry Virtual Tabletop
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 579
    • Issues 579
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 0
    • Merge Requests 0
  • Requirements
    • Requirements
    • List
  • Operations
    • Operations
    • Incidents
  • Analytics
    • Analytics
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • Foundry Network
  • Foundry Virtual TabletopFoundry Virtual Tabletop
  • Issues
  • #2454

Closed
Open
Opened Apr 06, 2020 by Andrew@aaclaytonOwner

Overview of the Socket Refactor

SocketInterface

The helper class SocketInterface has been reworked. Several methods have been deleted (effective immediately) including SocketInterface.trigger(), SocketInterface.triggerMany() SocketInterface.handle(), SocketInterface.handleMany(). If you were using these methods you will need to refactor your work to either call SocketInterface.dispatch() OR to simply call game.socket.emit() directly.

Multi-Entity and Multi-EmbeddedEntity Operations

The createMany, updateMany, and deleteMany methods have been deprecated in favor of greater flexibility in the base create(), update(), and delete() operations.

For example, instead of:

Actor.create(singleActorData, options); // creates one actor
Actor.createMany(arrayOfActorData, options); // creates many actors

You should now just use:

Actor.create(singleActorData, options); // creates one actor
Actor.create(arrayOfActorData, options); // creates many actors

The same holds true for EmbeddedEntity operations:

actor.createEmbeddedEntity("OwnedItem", singleItemData, options); // creates one item
actor.createEmbeddedEntity("OwnedItem", arrayOfItemData, options); // creates many items

Server Side Typescript

Implemented usage of Typescript for the server side database layer to ensure strict validations for all socket and database API contracts.

Hook Standardization

There was previously a disconnect with Hooks where the arguments provided to a hook could be slightly inconsistent depending on whether it was the pre-Hook or the post-Hook as well as whether it was the triggering client or a client receiving the broadcasted response. This was not intended and was a side effect of the previous SocketInterface's design choice which prevented the receiving client from always having the correct context. Database hooks should ALL now follow the same pattern.

Entity Hooks

preCreate<Entity>: [createData, options, userId]
create<Entity>: [entity, options, userId]
preUpdate<Entity>: [entity, updateData, options, userId]
update<Entity>: [entity, updateData, options, userId]
preDelete<Entity>: [entity, options, userId]
delete<Entity>: [entity, options, userId]

Embedded Entity Hooks

preCreate<EmbeddedEntity>: [parent, createData, options, userId]
create<EmbeddedEntity>: [parent, child, options, userId]
preUpdate<EmbeddedEntity>: [parent, child, updateData, options, userId]
update<EmbeddedEntity>: [parent, child, updateData, options, userId]
preDelete<EmbeddedEntity>: [parent, child, options, userId]
delete<EmbeddedEntity>: [parent, child, options, userId]

Callback Functions

The Entity callback functions have also changed their signatures to remain in parity with the hook definitions. If you are defining a custom Entity class (like an Actor subclass) you will need to update the following method signatures.

_onCreate(data, options, userId)
_onUpdate(data, options, userId);
_onDelete(options, userId);
_onCreateEmbeddedEntity(embeddedName, child, options, userId);
_onUpdateEmbeddedEntity(embeddedName, child, updateData, options, userId);
_onDeleteEmbeddedEntity(embeddedName, child, options, userId);
_onModifyEmbeddedEntity(embeddedName, changes, options, userId, context);

Note that these callback events will run for every entity or embedded entity that is updated through a DB operation.

Socket Namespace Consolidation

Consolidation to modifyDocument and modifyEmbeddedDocument socket events - Reduction from 156 named socket events to just 17.

Code Reorganization

Moved Entity and EmbeddedEntity handler definitions out of the Collection class into the Entity class itself. Greatly consolidated the bloat of the various Collection subclasses.

Edited Apr 11, 2020 by Andrew
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Beta 0.5.4
Milestone
Beta 0.5.4 (Past due)
Assign milestone
Time tracking
None
Due date
None
Reference: foundrynet/foundryvtt#2454