receiveMessages method
Future<DynamiteResponse<ChatReceiveMessagesResponseApplicationJson, ChatChatReceiveMessagesHeaders> >
receiveMessages({
- required String token,
- required ChatReceiveMessagesLookIntoFuture lookIntoFuture,
- ChatReceiveMessagesApiVersion? apiVersion,
- int? limit,
- int? lastKnownMessageId,
- int? lastCommonReadId,
- int? timeout,
- ChatReceiveMessagesSetReadMarker? setReadMarker,
- ChatReceiveMessagesIncludeLastKnown? includeLastKnown,
- ChatReceiveMessagesNoStatusUpdate? noStatusUpdate,
- ChatReceiveMessagesMarkNotificationsAsRead? markNotificationsAsRead,
- bool? oCSAPIRequest,
Receives chat messages from the given room.
- Receiving the history ($lookIntoFuture=0): The next $limit messages after $lastKnownMessageId will be returned. The new $lastKnownMessageId for the follow up query is available as
X-Chat-Last-Givenheader. - Looking into the future ($lookIntoFuture=1): If there are currently no messages the response will not be sent immediately. Instead, HTTP connection will be kept open waiting for new messages to arrive and, when they do, then the response will be sent. The connection will not be kept open indefinitely, though; the number of seconds to wait for new messages to arrive can be set using the timeout parameter; the default timeout is 30 seconds, maximum timeout is 60 seconds. If the timeout ends a successful but empty response will be sent. If messages have been returned (status=200) the new $lastKnownMessageId for the follow up query is available as
X-Chat-Last-Givenheader. The limit specifies the maximum number of messages that will be returned, although the actual number of returned messages could be lower if some messages are not visible to the participant. Note that if none of the messages are visible to the participant the returned number of messages will be 0, yet the status will still be 200. Also note thatX-Chat-Last-Givenmay reference a message not visible and thus not returned, but it should be used nevertheless as the $lastKnownMessageId for the follow-up query.
Returns a Future containing a DynamiteResponse with the status code, deserialized body and headers.
Throws a DynamiteApiException if the API call does not return an expected status code.
Parameters:
apiVersionDefaults to"v1".tokenlookIntoFuturePolling for new messages (1) or getting the history of the chat (0).limitNumber of chat messages to receive (100 by default, 200 at most). Defaults to100.lastKnownMessageIdThe last known message (serves as offset). Defaults to0.lastCommonReadIdThe last known common read message (so the response is 200 instead of 304 when it changes even when there are no messages). Defaults to0.timeoutNumber of seconds to wait for new messages (30 by default, 30 at most). Defaults to30.setReadMarkerAutomatically set the last read marker when 1, if your client does this itself via chat/{token}/read set to 0. Defaults to1.includeLastKnownInclude the $lastKnownMessageId in the messages when 1 (default 0). Defaults to0.noStatusUpdateWhen the user status should not be automatically set to online set to 1 (default 0). Defaults to0.markNotificationsAsReadSet to 0 when notifications should not be marked as read (default 1). Defaults to1.oCSAPIRequestRequired to be true for the API request to pass. Defaults totrue.
Status codes:
- 200: Messages returned
- 304: No messages
See:
- $receiveMessages_Request for the request send by this method.
- $receiveMessages_Serializer for a converter to parse the
Responsefrom an executed request.
Implementation
Future<_i1.DynamiteResponse<ChatReceiveMessagesResponseApplicationJson, ChatChatReceiveMessagesHeaders>>
receiveMessages({
required String token,
required ChatReceiveMessagesLookIntoFuture lookIntoFuture,
ChatReceiveMessagesApiVersion? apiVersion,
int? limit,
int? lastKnownMessageId,
int? lastCommonReadId,
int? timeout,
ChatReceiveMessagesSetReadMarker? setReadMarker,
ChatReceiveMessagesIncludeLastKnown? includeLastKnown,
ChatReceiveMessagesNoStatusUpdate? noStatusUpdate,
ChatReceiveMessagesMarkNotificationsAsRead? markNotificationsAsRead,
bool? oCSAPIRequest,
}) async {
final _request = $receiveMessages_Request(
token: token,
lookIntoFuture: lookIntoFuture,
apiVersion: apiVersion,
limit: limit,
lastKnownMessageId: lastKnownMessageId,
lastCommonReadId: lastCommonReadId,
timeout: timeout,
setReadMarker: setReadMarker,
includeLastKnown: includeLastKnown,
noStatusUpdate: noStatusUpdate,
markNotificationsAsRead: markNotificationsAsRead,
oCSAPIRequest: oCSAPIRequest,
);
final _streamedResponse = await _rootClient.httpClient.send(_request);
final _response = await _i3.Response.fromStream(_streamedResponse);
final _serializer = $receiveMessages_Serializer();
return _i1.ResponseConverter<ChatReceiveMessagesResponseApplicationJson, ChatChatReceiveMessagesHeaders>(
_serializer,
).convert(_response);
}