onNet - client
Use onNet
function when you want to listen from client AND from server.
This declares an event which gets triggered with emit (from client) or emitNet (from server).
Signature
function onNet(eventName: string, fn: Function) => void
Required arguments
- eventName: The event name you want to expose.
- fn: The function to execute when the event get triggered.
Examples
let myNameIs = "Carl";
onNet("foo:serverCalledYou", (newName: string) => {
myNameIs = newName;
console.warn(`Someone change your name to ${newName}`);
if (newName.toLowerCase() === "idiot") {
console.warn("Looks like he didn't like you.");
}
});
Last modified May 12, 2021: Typo on onNet client reference was misspelled (60c3356)