Delegate TurnEventHandler
Turn event handler to do something before or after a turn is run. Returning false from
beforeTurn
lets you prevent the turn from running and returning false from afterTurn
lets you prevent the Agents state from being saved.
Returning false from beforeTurn
does result in the Agents state being saved which lets you
track the reason why the turn was not processed. It also means you can use beforeTurn
as
a way to call into the dialog system. For example, you could use the OAuthPrompt to sign the
user in before allowing the AI system to run.
public delegate Task<bool> TurnEventHandler(ITurnContext turnContext, ITurnState turnState, CancellationToken cancellationToken)
Parameters
turnContext
ITurnContextA strongly-typed context object for this turn.
turnState
ITurnStateThe turn state object that stores arbitrary data for this turn.
cancellationToken
CancellationTokenA cancellation token that can be used by other objects or threads to receive notice of cancellation.
Returns
Constructors
TurnEventHandler(object, nint)
public TurnEventHandler(object @object, nint method)
Parameters
Methods
BeginInvoke(ITurnContext, ITurnState, CancellationToken, AsyncCallback, object)
public virtual IAsyncResult BeginInvoke(ITurnContext turnContext, ITurnState turnState, CancellationToken cancellationToken, AsyncCallback callback, object @object)
Parameters
turnContext
ITurnContextturnState
ITurnStatecancellationToken
CancellationTokencallback
AsyncCallbackobject
object
Returns
EndInvoke(IAsyncResult)
public virtual Task<bool> EndInvoke(IAsyncResult result)
Parameters
result
IAsyncResult
Returns
Invoke(ITurnContext, ITurnState, CancellationToken)
public virtual Task<bool> Invoke(ITurnContext turnContext, ITurnState turnState, CancellationToken cancellationToken)
Parameters
turnContext
ITurnContextturnState
ITurnStatecancellationToken
CancellationToken