How to know who send message to me?
dukepan2005 opened this issue · 2 comments
In the flutter project, I copy example code to test
tinode = Tinode('Moein', ConnectionOptions(apiKey: key, host: host, secure: false), false);
await tinode.connect();
await tinode.loginBasic('alice', 'alice123', null);
var me = tinode.getMeTopic();
me.onSubsUpdated.listen((value) {
for (var item in value) {
print('Subscription update: ' + item.public.toString() + ' - Unread Messages:' + item.unread.toString());
}
});
me.onContactUpdate.listen((value) {
print('Contact Update: ' + value.toString());
});
me.onPres.listen((value) {
print("Me Receive Pres message:" + value.toString());
});
// me.onAllMessagesReceived.listen((value) {
// print("All message receive:" + value.toString());
// });
// me.onInfo.listen((value) {
// print("Info event:" + value.toString());
// });
// me.onMetaSub.listen((value) {
// print("meta sub event:" + value.toString());
// });
await me.subscribe(MetaGetBuilder(me).withLaterSub(null).build(), null);
var grp = tinode.getTopic('grpT9wlZYxma0Q');
grp.onData.listen((value) {
if (value != null) {
print('DataMessage: ' + value.content);
}
});
await grp.subscribe(MetaGetBuilder(grp).withLaterSub(null).withLaterData(null).build(), null);
var msg = grp.createMessage('This is cool', true);
await grp.publishMessage(msg);
When I login in by another account, and send a message to the group. I can see log: DataMessage: xxxx
But can't see any log If sending a message to the user "alice" directly.
- what event should be bind to get who sends a message and what's the message content?
- Are there any plan to explain dart sdk?
It seems we should check me.contacts, but following exception occur:
Unhandled Exception: type '_CompactIterable' is not a subtype of type 'List'
How to iterate me.contacts?
Sorry for answering late.
When I login in by another account, and send a message to the group. I can see log: DataMessage: xxxx
But can't see any log If sending a message to the user "alice" directly.
If you want to get messages from any topic you need to subscribe on that topic first.
Are there any plan to explain dart sdk?
Yes after testing I'm going to write the docs.
How to iterate me.contacts?
It was a bug and it's fixed now.