Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ActionManager

A class to manage and apply actions on a Canvas.

Hierarchy

  • ActionManager

Index

Constructors

constructor

Properties

canvas

canvas: Canvas

Canvas where to apply Actions.

doneActions

doneActions: Action[]

List of done actions.

queueActions

queueActions: Action[]

List of actions, applied to a shape that doesn't allready exist.

undoneActions

undoneActions: Action[]

List of undone actions.

Static createdShapes

createdShapes: string[] = []

List of created shapes.

Static deletedShapes

deletedShapes: string[] = []

List of deleted shapes.

Static lastPeerTimeStamps

lastPeerTimeStamps: [string, number][] = []

associate each peer connected to the last timestamp he sended

Static timeStamp

timeStamp: number = 0

Current value of the clock.

Static userId

userId: string = ""

Id of the user.

Methods

do

manageActions

  • manageActions(action: Action): void
  • Manage the execution an action that has been received and add it to the doneAction list if the first action is executed on a not existing shape, add it to the queue list if an action is in concurrency with a previous one, execute the "promote" function

    Parameters

    • action: Action

      action that just arrived and hasn't been processed yet

    Returns void

promote

  • promote(action: Action): void
  • Manage a problem of concurrency due to a new action, by undoing action that should be executed after the new function, and then re executing all of them in the correct order.

    Parameters

    • action: Action

      the new action, in concurrency with the previous ones

    Returns void

rankActions

  • Returns -1 if the action a has a timeStamp below the b action or if it's id is below, if not return 1.

    Parameters

    • a: Action

      first action that will be compared.

    • b: Action

      second action that will be compared.

    Returns number

setupEventListeners

  • setupEventListeners(): void

undo

update

  • update(action: Action): void
  • set the time stamp to the max between the current time stamp and the last time stamp received from a peer delete all the previous actions which have a time stamp as it can't receive a message concurrent to it anymore.

    Parameters

    • action: Action

      the new action that just has been executed

    Returns void

Static addNewPeer

  • addNewPeer(peerId: string): void
  • add a new peer to the list of the peer time stamps, his time stamp is set to 0

    Parameters

    • peerId: string

      the id of the new connected peer

    Returns void

Static getTimeStamp

  • getTimeStamp(): number

Static removePeer

  • removePeer(peerId: string): void
  • add a new peer to the list of the peer time stamps, his time stamp is set to 0

    Parameters

    • peerId: string

      the id of the new connected peer

    Returns void

Generated using TypeDoc