Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -66,45 +66,35 @@ class Events(
)

/**
* Publish a single event to a channel.
* Publish a single event to a channel over REST POST.
*
* @param channelName of the channel to publish to.
* @param event formatted in json.
* @param authorizer for the publish call. If not provided, the EventChannel publish authorizer will be used.
* @return result of publish.
*/
@Throws(EventsException::class)
suspend fun publish(
channelName: String,
event: JsonElement,
authorizer: AppSyncAuthorizer = this.defaultChannelAuthorizers.publishAuthorizer
): PublishResult {
return try {
httpClient.post(channelName, authorizer, event)
} catch (exception: Exception) {
throw exception.toEventsException()
}
return httpClient.post(channelName, authorizer, event)
}

/**
* Publish a multiple events (up to 5) to a channel.
* Publish a multiple events (up to 5) to a channel over REST POST.
*
* @param channelName of the channel to publish to.
* @param events list of formatted json events.
* @param authorizer for the publish call. If not provided, the EventChannel publish authorizer will be used.
* @return result of publish.
*/
@Throws(EventsException::class)
suspend fun publish(
channelName: String,
events: List<JsonElement>,
authorizer: AppSyncAuthorizer = this.defaultChannelAuthorizers.publishAuthorizer
): PublishResult {
return try {
httpClient.post(channelName, authorizer, events)
} catch (exception: Exception) {
throw exception.toEventsException()
}
return httpClient.post(channelName, authorizer, events)
}

/**
Expand All @@ -117,7 +107,7 @@ class Events(
fun channel(
channelName: String,
authorizers: ChannelAuthorizers = this.defaultChannelAuthorizers,
) = EventsChannel(channelName, authorizers, eventsWebSocketProvider, json)
) = EventsChannel(channelName, authorizers, eventsWebSocketProvider)

/**
* Method to disconnect from all channels.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class EventsChannel internal constructor(
}

/**
* Publish a single event to a channel.
* Publish a single event to a channel over WebSocket.
*
* @param event formatted in json.
* @param authorizer for the publish call. If not provided, the EventChannel publish authorizer will be used.
Expand All @@ -93,7 +93,7 @@ class EventsChannel internal constructor(
}

/**
* Publish a multiple events (up to 5) to a channel.
* Publish a multiple events (up to 5) to a channel over WebSocket.
*
* @param events list of formatted json events.
* @param authorizer for the publish call. If not provided, the EventChannel publish authorizer will be used.
Expand Down