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 get the connected peers details? #106

Closed
habibrosyad opened this issue Nov 26, 2020 · 7 comments · Fixed by #123
Closed

How to get the connected peers details? #106

habibrosyad opened this issue Nov 26, 2020 · 7 comments · Fixed by #123
Labels
enhancement 🌟 New feature or request good first issue 🐤 Good for newcomers question 💭 Further information is requested

Comments

@habibrosyad
Copy link
Contributor

habibrosyad commented Nov 26, 2020

Thanks for the amazing works.

I've just started experimenting with yorkie and stumbled upon an issue. I noticed that we can display peers accessing a document in realtime (as found in this example). However, it is limited to get the peer ids (the id which is returned by the agent on client activation).

Is there a way to get more details (perhaps the key used on activation)?

My use case is that I'm trying to build a real time text editor, similar with Google Docs. I would like to display all user names accessing the document (not just the ids). I'm thinking of putting the client's key with the user id, so that I could retrieve more details (e.g. username) later in the other connected peer sessions. However, I could not find out how to do that. Maybe I'm missing something here.

@hackerwins hackerwins added enhancement 🌟 New feature or request question 💭 Further information is requested labels Nov 27, 2020
@hackerwins
Copy link
Member

The peer awareness feature is not yet fully implemented. We were thinking about how to pass additional information of the client. Since Yorkie is not yet released to users, we are trying to design an API while implementing an example(CodePair). Do you have any good ideas?

@habibrosyad
Copy link
Contributor Author

I've setup a demo on my experiments for this in https://habibrosyad.github.io/yorkie-js-sdk/ (Quill demo with peers), where you could set your own username with query param username in the link (otherwise it's randomly generated).

To add peer details, I use an additional meta field (basically a Map<string,string>) when creating a client. In this field you could put whatever details related with the client there. The meta then persisted during client activation and can be fetched later during the documents-watching-peer-changed event. To accommodate this I've modified the proto a bit.

This is just a rough experiment, and I'm not sure yet that this is an ideal approach. The changes that I've made for this can be seen in habibrosyad/yorkie@14ed7e1 and habibrosyad@0111683.

@hackerwins hackerwins added the good first issue 🐤 Good for newcomers label Nov 30, 2020
@hackerwins
Copy link
Member

@habibrosyad
Thank you for explaining the experiment. Storing metadata on the client seems like a good approach. I think we may refer to this experiment and implement it.

While looking at the experiment, I was wondering how to get client meta info from WatchDocuments without calling rpc GetClients().

@habibrosyad
Copy link
Contributor Author

@hackerwins I think I've got a better approach than the previous one. I play around with the WatchDocuments. Instead of persisting meta during client activation (and saving it in the db), I pass it as part of the WatchDocumentsRequest. The peer id and meta become the value of the event documents-watching-peer-changed (changed from list of peer ids into map of <peer id, peer meta>). Also, I removed the GetClients because it is not needed anymore.

The changes made for this can be seen here in yorkie and yorkie-js-sdk. Should I make a PR for this issue?

@hackerwins
Copy link
Member

hackerwins commented Dec 1, 2020

@habibrosyad Cool! 👍 It seems to be much lighter than the previous approach. If you create PRs(yorkie and yorkie-js-sdk), I will review it with other members.

@hackerwins
Copy link
Member

hackerwins commented Jan 5, 2021

@habibrosyad
Thanks to your help, we have added metadata to the Peer Awareness. And I am working on a related design document. Can you review the document? yorkie-team/yorkie#139

@habibrosyad
Copy link
Contributor Author

@habibrosyad
Thanks to your help, we have added metadata to the Peer Awareness. And I am working on a related design document. Can you review the document? yorkie-team/yorkie#139

sure 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement 🌟 New feature or request good first issue 🐤 Good for newcomers question 💭 Further information is requested
Projects
None yet
2 participants