SignalAwaiter
A one-shot signal awaiter producing Variant[].
Normally use await receiver.ToSignal(source, signal). Creating SignalAwaiter connects the wait; the next signal completes it. If the signal never arrives or the owner disappears, automatic completion is not guaranteed. This type has no built-in CancellationToken or timeout.
The example expects exactly one string argument, copies it into a C# string and disposes the received Variants. Call ReadOnceAsync before emitting the signal; receiver and emitter must remain alive. The example adds no cancellation.
using System;
using System.Threading.Tasks;
using Reckfell;
public static class SignalTextExample
{
// Call before the emitter sends its next signal. Both objects must stay alive.
public static async Task<string> ReadOnceAsync(Entity receiver, Entity emitter, StringName signal)
{
Variant[] values = await receiver.ToSignal(emitter, signal);
try
{
if (values.Length != 1 || values[0].VariantType != Variant.Type.String)
throw new InvalidOperationException("Expected one string signal argument.");
return values[0].AsString();
}
finally
{
foreach (Variant value in values)
value.Dispose();
}
}
}GetAwaiter returns the same instance. For the next event, create a new wait through ToSignal. Do not dispose the same argument array again when rereading GetResult.
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Constructors1
SignalAwaiterConstructor
public SignalAwaiter(ReckfellObject source, StringName signal, ReckfellObject target);Immediately connects a one-shot wait for source to emit signal, associated with target. Both objects must be alive and the signal must exist. Does not emit the signal. For ordinary gameplay code prefer receiver.ToSignal(source, signal). The constructor returns no Error; a connection failure does not promise await completion or a CLR exception.
| Name | Type | Default |
|---|---|---|
source | ReckfellObject | — |
signal | StringName | — |
target | ReckfellObject | — |
sourceLive object that is expected to emit the signal.
signalName of an existing source signal; that signal defines the result arguments.
targetLive receiver associated with the native callable. This role is separate from source; ToSignal uses the calling object as target. Do not free it while waiting.
Properties1
IsCompletedProperty
public bool IsCompleted { get; }Initially false; signal delivery sets it to true before invoking the continuation. Indicates signal receipt, not source or target liveness. Removing the owner does not necessarily set it to true.
Methods3
GetAwaiterIAwaiter<Variant[]>
public IAwaiter<Variant[]> GetAwaiter();Returns this same instance as IAwaiter<Variant[]>. Does not create another connection or start a new wait. Awaiting an already completed instance obtains its stored result.
IAwaiter<Variant[]>The same object exposed as IAwaiter<Variant[]>.
GetResultVariant[]
public Variant[] GetResult();Returns the stored argument array without waiting or copying it again. Before completion, the current implementation returns null despite the non-nullable signature: use await or call only after IsCompleted. After signal delivery the array contains owned Variant copies; dispose each element once after use. Repeated GetResult calls return the same array, not independent values.
Variant[]After delivery, signal arguments in their original order; an empty array for a signal with no arguments. Before delivery, null in the current implementation.
OnCompletedvoid
public void OnCompleted(Action continuation);Stores one continuation; another call replaces the previous one. Signal delivery invokes the saved action directly from the callback after setting the result and IsCompleted. Calling this method after completion does not itself invoke the action. This is part of the await protocol: use await in ordinary code rather than manual registration. It is neither a thread dispatcher nor a subscription to every signal.
| Name | Type | Default |
|---|---|---|
continuation | Action | — |
continuationContinuation to invoke on completion; not a list of independent handlers.