getChatMessages method
Retrieves chat messages for a specific trade by its trade ID.
Sends a GetChatMessagesRequest to fetch messages from the trade's chat. If the client is not connected, a DaemonNotConnectedException is thrown.
Example:
final messages = await tradesService.getChatMessages('tradeId');
for (final message in messages) {
print('Message: ${message.text}');
}
Returns:
- A
Future
containing aList<ChatMessage>
of chat messages for the trade.
Implementation
Future<List<ChatMessage>> getChatMessages(String tradeId) async {
if (!havenoChannel.isConnected) {
throw DaemonNotConnectedException();
}
try {
final getChatMessagesReply = await havenoChannel.tradesClient!
.getChatMessages(GetChatMessagesRequest(tradeId: tradeId));
return getChatMessagesReply.message;
} on GrpcError catch (e) {
handleGrpcError(e);
return [];
}
}