createMetaData method
Creates meta data on this channel with metaData
.
It returns Map<String, String> that newly created. Once it completes successfully, channel event ChannelEventHandler.onMetaDataCreated will be invoked.
Implementation
Future<Map<String, String>> createMetaData(
Map<String, String> metaData) async {
if (metaData.isEmpty) {
throw InvalidParameterError();
}
final result = await _sdk.api.send<MetaDataResponse>(
ChannelMetaDataCreateRequest(
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;
}