Skip to content

Commit

Permalink
First commit for RTM 2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
littleGnAl committed Sep 6, 2024
1 parent db1ea30 commit 1582c95
Showing 1 changed file with 8 additions and 26 deletions.
34 changes: 8 additions & 26 deletions example/lib/src/rtm_api_demo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ class _RtmApiDemoState extends State<RtmApiDemo> {
await RTM(config.appId, _userIdController.text);
if (status.error) {
logSink.log(
'[error] operation: ${status.operation}, reason: ${status.reason}');
'[error] errorCode: ${status.errorCode}, operation: ${status.operation}, reason: ${status.reason}');
return;
}
_rtmClient = client;
Expand Down Expand Up @@ -264,11 +264,9 @@ class _RtmApiDemoState extends State<RtmApiDemo> {
_button('RtmClient.unsubscribe', () async {
final (status, result) =
await _rtmClient.unsubscribe(_channelNameController.text);
if (status.error) {
return;
}

logSink.log(
'[UnsubscribeResult] channelName: ${result!.channelName}, errorCode: ${status.errorCode}');
'[UnsubscribeResult] channelName: ${result?.channelName}, errorCode: ${status.errorCode}');
}),
],
),
Expand Down Expand Up @@ -312,12 +310,9 @@ class _RtmApiDemoState extends State<RtmApiDemo> {
recordUserId: _isSetChannelMetadataRecordUserId,
lockName: _setChannelMetadataLockNameController.text,
);
if (status.error) {
return;
}

logSink.log(
'[SetChannelMetadataResult] channelName: ${result!.channelName}, channelType: ${result.channelType}, errorCode: ${status.errorCode}');
'[SetChannelMetadataResult] channelName: ${result?.channelName}, channelType: ${result?.channelType}, errorCode: ${status.errorCode}');
}),
_button('RtmStorage.updateChannelMetadata', () async {
final storage = _rtmClient.getStorage();
Expand All @@ -339,12 +334,8 @@ class _RtmApiDemoState extends State<RtmApiDemo> {
lockName: _setChannelMetadataLockNameController.text,
);

if (status.error) {
return;
}

logSink.log(
'[UpdateChannelMetadataResult] channelName: ${result!.channelName}, channelType: ${result.channelType}, errorCode: ${status.errorCode}');
'[UpdateChannelMetadataResult] channelName: ${result?.channelName}, channelType: ${result?.channelType}, errorCode: ${status.errorCode}');
}),
_button('RtmStorage.removeChannelMetadata', () async {
final storage = _rtmClient.getStorage();
Expand All @@ -360,23 +351,17 @@ class _RtmApiDemoState extends State<RtmApiDemo> {
.toList(),
lockName: _setChannelMetadataLockNameController.text,
);
if (status.error) {
return;
}

logSink.log(
'[RemoveChannelMetadataResult] channelName: ${result!.channelName}, channelType: ${result.channelType}, errorCode: ${status.errorCode}');
'[RemoveChannelMetadataResult] channelName: ${result?.channelName}, channelType: ${result?.channelType}, errorCode: ${status.errorCode}');
}),
_button('RtmStorage.getChannelMetadata', () async {
final storage = _rtmClient.getStorage();
final (status, result) = await storage.getChannelMetadata(
_channelNameController.text, _rtmChannelType);
if (status.error) {
return;
}

logSink.log(
'[GetChannelMetadataResult] channelName: ${result!.channelName}, channelType: ${result.channelType}, data: ${result.data.toJson()} errorCode: ${status.errorCode}');
'[GetChannelMetadataResult] channelName: ${result?.channelName}, channelType: ${result?.channelType}, data: ${result?.data.toJson()} errorCode: ${status.errorCode}');
}),
],
),
Expand Down Expand Up @@ -406,12 +391,9 @@ class _RtmApiDemoState extends State<RtmApiDemo> {
includeUserId: _isWhoNowIncludeUserId,
page: _isWhoNowPageController.text,
);
if (status.error) {
return;
}

logSink.log(
'[WhoNowResult] userStateList: [${result!.userStateList.map((e) => e.toJson())}], nextPage: ${result.nextPage}, errorCode: ${status.errorCode}');
'[WhoNowResult] userStateList: [${(result?.userStateList ?? []).map((e) => e.toJson())}], nextPage: ${result?.nextPage}, errorCode: ${status.errorCode}');
}),
],
),
Expand Down

0 comments on commit 1582c95

Please sign in to comment.