getEvent Method

Get IModelHubEvent from the EventSubscription. You can use long polling timeout, to have requests return when events are available (or request times out), rather than returning immediately when no events are found.

getEvent(requestContext: ClientRequestContext, sasToken: string, baseAddress: string, subscriptionId: string, timeout?: number): Promise<IModelHubEvent | undefined>

throws IModelHubClientError with IModelHubStatus.UndefinedArgumentError or IModelHubStatus.InvalidArgumentError if one of the arguments is undefined or has an invalid value.

throws ResponseError if request has failed.

Parameter Type Description
requestContext ClientRequestContext The client request context
sasToken string SAS Token used to authenticate. See EventSAS.sasToken.
baseAddress string Address for the events. See EventSAS.baseAddress.
subscriptionId string Id of the subscription to the topic. See EventSubscription.
timeout number Optional timeout duration in seconds for request, when using long polling.

Returns - Promise<IModelHubEvent | undefined>

IModelHubEvent if it exists, undefined otherwise.

Defined in

Last Updated: 13 June, 2024