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).
function onNet(eventName: string, fn: Function) => void
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.");
}
});