MCPcopy
hub / github.com/alm-tools/alm / setupAllCast

Method setupAllCast

src/socketLib/socketLibServer.ts:46–62  ·  view source on GitHub ↗

* Mutates the original in place plus returns the mutated version * Each member of `instance` must be a typed event

(instance: T)

Source from the content-addressed store, hash-verified

44 * Each member of `instance` must be a typed event
45 */
46 setupAllCast<T>(instance: T): T {
47 var toRet = instance;
48 Object.keys(toRet).forEach(name => {
49 // Override the actual emit function with one that sends it on to the server
50 const evt = new TypedEvent();
51 toRet[name] = evt;
52 evt.on((data: T) => {
53 let castMessage: CastMessage<T> = {
54 message: name,
55 data: data
56 };
57 // console.log('EMIT TO ALL : ', name)
58 this.io.sockets.emit(anycastMessageName, castMessage);
59 });
60 });
61 return toRet;
62 }
63}
64
65export class ServerInstance extends RequesterResponder {

Callers 1

runFunction · 0.95

Calls 4

forEachMethod · 0.65
keysMethod · 0.65
onMethod · 0.65
emitMethod · 0.65

Tested by

no test coverage detected