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

Add uid parameter to publish command to allow client to define uid #204

Conversation

vladshut
Copy link
Contributor

@vladshut vladshut commented Feb 8, 2018

This functionality allows to push notification with specified uid to centrifugo. Also server can send notifications directly (without centrifugo) to client with specified uid and client can fetch notifications from centrifugo started from specified uid by server.

@FZambia
Copy link
Member

FZambia commented Feb 9, 2018

@vladshut thanks, this is much better than previous approach.

But I am still waiting for real use case information behind this change. Could you describe it in details?

@vladshut
Copy link
Contributor Author

vladshut commented Feb 9, 2018

@FZambia
This functionality allows to push notification with specified uid to centrifugo. Also server can send notifications directly (without centrifugo) to client with specified uid and client can fetch notifications from centrifugo started from specified uid by server.

@damour
Copy link

damour commented Feb 9, 2018

Hi @FZambia ! Thanks for prompt response. Some background. At our site in header user can see his message counter (in internal mail). Frontend is classic web application (not single-page application) so after some actions page reloads. After page loading/reloading user see his message counter. Then we subscribe to user notification channel and update message counter.
Backend - microservices that communicates via async messages.

Problem: user can missing some messages.

Registration use case:

  • user click "register" button, controller in user service push welcome message to user notification channel, sends async UserRegistered message to message bus and return response to user.
  • page loaded, user see 1 message.
    ... at this moment background workers sends another messages to user
  • we subscribe to user channel.

Result: user see 1 message.
Expected result: user see 2 messages in message box.

Proposed solution: when page rendering we store last message uid with counter. Then in subscribe command we provide last id: {channel: "notifications", last: lastMessageUId, recover: true}. So centrifugo restore messages and user see actual info.

@FZambia
Copy link
Member

FZambia commented Feb 9, 2018

@damour thanks for detailed explanation, do you need assistance from centrifuge-js side for this to work? Looks like you need this pr to be merged?

@damour
Copy link

damour commented Feb 9, 2018

We use centrifugo beyond api gateway:
client (graphql subscription) -> api gateway(nodejs websocket client) -> centrifugo.
Therefore, for us it is not mandatory, but for other users it will definitely be useful. Thanks!

@FZambia FZambia merged commit 80ff993 into centrifugal:master Feb 10, 2018
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

Successfully merging this pull request may close these issues.

3 participants