CommandRegistry - element-ts/lithium GitHub Wiki
The command registry is how all messages are managed internally. When a command is invoked, a message is created by
the socket's command registry. It generate a new non-colliding id
for the message and adds the message and the
message's completion handler to the internal map.
When you setup either a LiSocket
or LiServer
you provide generic parameters that conform to
LiCommandRegistryStructure
. There are three types of possible command registries.
LC
)
Local Command Registry (The local command registry is referred to as LC
in parameters. These are the commands that the socket will implement.
RC
)
Remote Command Registry (The remote command registry is referred to as RC
in parameters. These are the commands that the socket will invoke.
SC
)
Sibling Command Registry (The sibling command registry is referred to as SC
in parameters. These are the commands that the socket can invoke on
its siblings.
Creating a Registry
To create a registry, just make an interface that extends LiCommandRegistryStructure
like below:
export interface MyServerCommands extends LiCommandRegistryStructure {
changeFavoriteNumber: {
param: number;
return: void;
};
getFavoriteColor: {
param: void;
return: number;
};
}