updateMetaData method
Updates meta data on this channel with metaData
.
It returns Map<String, String> that newly updated. Once it completes successfully, channel event ChannelEventHandler.onMetaDataUpdated will be invoked.
Implementation
Future<Map<String, String>> updateMetaData(
Map<String, String> metaData) async {
if (metaData.isEmpty) {
throw InvalidParameterError();
}
final result = await _sdk.api.send<MetaDataResponse>(
ChannelMetaDataUpdateRequest(
channelType: channelType,
channelUrl: channelUrl,
metaData: metaData,
),
);
final cached = _sdk.cache.find<CachedDataMap>(channelKey: channelUrl) ??
CachedDataMap<String>(
channelType: channelType,
channelUrl: channelUrl,
timestamp: result.ts,
);
cached.addMap(result.metadata, result.ts);
cached.saveToCache();
return result.metadata;
}