Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use the library? #14

Open
XuanTung95 opened this issue Aug 31, 2021 · 15 comments
Open

How to use the library? #14

XuanTung95 opened this issue Aug 31, 2021 · 15 comments

Comments

@XuanTung95
Copy link

After login, I cannot figure out how to do these things:

  • Get list of topic
  • Find other user
  • Get list message of topic
  • Listen to the incoming message of topic.
  • Listen to the typing message.

Can you add more examples for these?

@c1s1x1
Copy link

c1s1x1 commented Aug 31, 2021

This library has very few features and I can answer some of your questions. I also hope to work with you to solve some problems with this library.
I've been using this library for about two weeks now, and some of the solutions need to be verified by you
另外你是中国人吗?

@c1s1x1
Copy link

c1s1x1 commented Aug 31, 2021

1:Get list of topic
var me = MySingleton.tinode.getMeTopic();
MySingleton.tinode.onRawMessage.listen((value) {
Get the list of topic here
}
var info = await me.subscribe(im.MetaGetBuilder(me).withLaterSub(null).withDesc(null).withTags().withCred().build(), null);

@c1s1x1
Copy link

c1s1x1 commented Aug 31, 2021

2:Find other user
Same as the first question,only Need to change here
MySingleton.tinode.getFndTopic();

@c1s1x1
Copy link

c1s1x1 commented Aug 31, 2021

The third problem, which is in the demo

@XuanTung95
Copy link
Author

@c1s1x1 Thank for the info.
After investigate I find that.
1- Get list of topic can use

tinode.getMeTopic().onSubsUpdated.listen((value) {
  for (var item in value) {
    Topic topic = tinode.getTopic(item.topic ?? '');
  }
})

4- Listen to the incoming message of topic. can use

tinode.subscribe(
              topic.name ?? '',
              MetaGetBuilder(me)
                  .withLaterSub(null)
                  .withDesc(null)
                  .withTags()
                  .withCred()
                  .build(),
              SetParams());
topic.onData.listen((DataMessage? value) {
            print("data: ${value?.content}");
          });

5- Listen to the typing message. can use

topic.onInfo.listen((InfoMessage value) {
            print('${value.topic}  ${value.what}');
          });

2 and 3 still have no idea how to do it.

@c1s1x1
Copy link

c1s1x1 commented Sep 1, 2021

Sorry, I have a problem answering the first question, I should use onSubsUpdated listener.
2:Find other user

var me =tinode.getFndTopic();
tinode.onRawMessage.listen((value) { 
    Find other user 
};
await me.subscribe(
          MetaGetBuilder(me)
          .withLaterSub(null)
          .withDesc(null)
          .withTags()
          .withCred()
          .build(), null);

image
By the way, what country are you from?

@c1s1x1
Copy link

c1s1x1 commented Sep 1, 2021

The third question I did not understand

@XuanTung95
Copy link
Author

I'm from Viet Nam.

  • Get list message of topic: I mean load previous messages from the server. It should be pagination I think.
  • Find other user: I don't understand how to find multiple times with different keywords if you only subscribe one time. There must be other way.

@c1s1x1
Copy link

c1s1x1 commented Sep 1, 2021

  • Get list message of topic: Well, I don't know how to load previous messages from the server.
  • Find other user: I didn't find a way to search by different keywords.I also need this feature

@cfanboy
Copy link

cfanboy commented Sep 1, 2021

@c1s1x1 I strongly recommend you to read the Tinode server API document first, then use dart-sdk.

@c1s1x1
Copy link

c1s1x1 commented Sep 1, 2021

@c1s1x1 I strongly recommend you to read the Tinode server API document first, then use dart-sdk.

老哥,我看过服务器端的文档,后台支持的功能,不代表flutter端就有对应的接口功能啊,肯定是在不改动源码的基础上使用最好。就好比tinodewWeb端支持文件图片传输,flutter端就不支持,必须改源码才可以。
如果你也看过flutter端,能回答一下怎么去创建新topic和添加成员吗?最近卡在这里了

@XuanTung95
Copy link
Author

OK so basically we can send all kind of message same as js client,
message type is defined in package-types.dart

const String Hi = 'hi';
const String Acc = 'acc';
const String Login = 'login';
const String Sub = 'sub';
const String Leave = 'leave';
const String Pub = 'pub';
const String Get = 'get';
const String Set = 'set';
const String Del = 'del';
const String Note = 'note';
  • To get of previous messages of topic:
tinode.getMeta(
                        topic.name ?? '',
                        MetaGetBuilder(topic)
                            .withData(
                                null,
                                topic.messages.isEmpty
                                    ? null
                                    : topic.messages.first.seq,
                                20)
                            .build(),
                      );
  • To find other user, which I copy from js:
var res = await tinode.getFndTopic().setMeta(SetParams(
  desc: TopicDescription(
    public: 'keyword',
  )));
res = await tinode.getFndTopic().getMeta(
    MetaGetBuilder(tinode.getFndTopic()).withSub(
        null, null, null).build()
);

@cfanboy Could you post the link to the doc here?

@c1s1x1
Copy link

c1s1x1 commented Sep 2, 2021

OK so basically we can send all kind of message same as js client,
message type is defined in package-types.dart

const String Hi = 'hi';
const String Acc = 'acc';
const String Login = 'login';
const String Sub = 'sub';
const String Leave = 'leave';
const String Pub = 'pub';
const String Get = 'get';
const String Set = 'set';
const String Del = 'del';
const String Note = 'note';
  • To get of previous messages of topic:
tinode.getMeta(
                        topic.name ?? '',
                        MetaGetBuilder(topic)
                            .withData(
                                null,
                                topic.messages.isEmpty
                                    ? null
                                    : topic.messages.first.seq,
                                20)
                            .build(),
                      );
  • To find other user, which I copy from js:
var res = await tinode.getFndTopic().setMeta(SetParams(
  desc: TopicDescription(
    public: 'keyword',
  )));
res = await tinode.getFndTopic().getMeta(
    MetaGetBuilder(tinode.getFndTopic()).withSub(
        null, null, null).build()
);

@cfanboy Could you post the link to the doc here?

https://github.com/tinode/chat/blob/master/docs/API.md here

@c1s1x1
Copy link

c1s1x1 commented Sep 2, 2021

I'm from Viet Nam.

  • Get list message of topic: I mean load previous messages from the server. It should be pagination I think.
  • Find other user: I don't understand how to find multiple times with different keywords if you only subscribe one time. There must be other way.

now I can get historical data,but it seems that I have to change the source code

await grp!.subscribe(
        MetaGetBuilder(grp!)
        .withSub(null, null, null)
        .withData(null,null,24)
        .withDesc(this.topicSubscription.touched)
        .build(), null);

It's changed here, but I'm not sure if the change will have any impact
image

image

First time to get historical data without any problem,but When I get the history message for the second time, I get an array out of bounds error
image
image

I think there is a bug here. so,I made a simple change to replace when the exact same message is matched
image

@NetFly-VPN
Copy link

@c1s1x1 这个库,你用的怎么样, 现在有人想找人基于tinode做一个简易的客服系统, 如果有兴趣可以Telegram联系: @miaomiao_c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants