Signal¶
-
SignalConstruction:
Signal newObj = Signal();
Clone:Signal newObj = Signal(other);
Signal maintains a list of Method to be invoked when a signal is triggered.
Static Methods¶
Methods¶
- void Connect(Method aMethod)¶
Connects a Method to the signal. The method will be executed when Call is invoked.
- void Connect(string aFunctionName)¶
- void Connect(Object aBaseObject, string aMethodName)¶
First creates a Method given the global function name or an object and a method name. The resulting method is then connected to the signal.
- void Disconnect(string aFunctionName)¶
- void Disconnect(Object aBaseObject, string aMethodName)¶
- void Disconnect(Method aMethod)¶
Disconnects a Method from the signal.
- void DisconnectAll()¶
Disconnects all methods from the signal.
- Array<Object> Call()¶
- Array<Object> Call(Array<Object> aParams)¶
Invokes all connected methods with the specified parameter list. It is the responsibility of the user to ensure method arguments match. Returns a list of return values from each method.
- int Size()¶
Returns the number of methods connected to this signal.
- Array<Method> Methods()¶
Returns an array of all connected methods.
Example¶
Demonstrates basic usage of Signal:
platform_type plat_type WSF_PLATFORM
script void report(string aParm)
writeln(Name(), " says ", aParm);
end_script
on_initialize
Signal sig = Signal.Global("report_status");
sig.Connect(PLATFORM, "report");
end_on_initialize
end_platform_type
platform plat-1 plat_type end_platform
platform plat-2 plat_type end_platform
execute at_time 1 s absolute
Signal.Global("report_status").Call( {"Hello World"} );
end_execute
outputs:
plat-1 says Hello World
plat-2 says Hello World