handleChatEvent static method
dynamic
handleChatEvent(
- dynamic data, [
- dynamic includeRaw = false
Implementation
static handleChatEvent(dynamic data, [includeRaw = false]) {
if (data == null) {
log('Error in handleChatEvent: data is undefined or null');
throw Exception('data is undefined or null');
}
final eventTypeMap = {
'Chat': MessageEventType.message,
'Request': MessageEventType.request,
'Approve': MessageEventType.accept,
'Reject': MessageEventType.reject,
};
var key = data['eventType'] ?? data['messageCategory'];
if (!eventTypeMap.containsKey(key)) {
throw FormatException('Invalid eventType or messageCategory in data');
}
final eventType = eventTypeMap[key];
if (eventType != null) {
return mapToMessageEvent(data, includeRaw, eventType);
} else {
log('Unknown eventType: ${data['eventType'] ?? data['messageCategory']}');
return data;
}
}