Skip to content

Commit

Permalink
docs(master): Add comments to clarify types
Browse files Browse the repository at this point in the history
  • Loading branch information
delucis committed Sep 13, 2021
1 parent 1692ae4 commit a35eba6
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/master/master.ts
Expand Up @@ -54,6 +54,9 @@ type CallbackFn = (arg: {
action?: ActionShape.Any | CredentialedActionShape.Any;
}) => void;

/**
* Data types that are shared across `TransportData` and `IntermediateTransportData`.
*/
type CommonTransportData =
| {
type: 'sync';
Expand All @@ -68,6 +71,10 @@ type CommonTransportData =
args: [string, ChatMessage];
};

/**
* Final shape of data sent by the transport API
* to be received by clients/client transports.
*/
export type TransportData =
| {
type: 'update';
Expand All @@ -79,6 +86,10 @@ export type TransportData =
}
| CommonTransportData;

/**
* Data type sent by a master to its transport API. The transport then transforms
* this into `TransportData` for each individual player it forwards it to.
*/
export type IntermediateTransportData =
| {
type: 'update';
Expand All @@ -90,6 +101,7 @@ export type IntermediateTransportData =
}
| CommonTransportData;

/** API used by a master to emit data to any connected clients/client transports. */
export interface TransportAPI {
send: (
playerData: { playerID: PlayerID } & IntermediateTransportData
Expand Down

0 comments on commit a35eba6

Please sign in to comment.