Update UI components from one user request to all active users

Hello, I’m Vlad.
I’m a beginner in Vaadin and I is developing a site for playing chess online. And I have such problem: I want to update all users UI whose connected to the server when one of the users click on the button “Create a game”. On other user’s UI must reveal a new layout with the label “Such player created a game” and button “Connect to the game”. And when one of users whose receive that message has clicked the button other users UI must remove that layout. In short, how can we get access from one user to other users and identify one user from other users?

One of the vaaadin samples has a ‘MessageBus’ for transmitting data between sessions.

This is more a java issue.

You need to setup a singleton.

Have each vaadin session register as a listener on the singleton.

When a user creates a board, call a method on the singleton which then calls each registered listener.

Each listener will run in a non-ui thread so you will need to use the UI.access method before you make any ui changes.

Each listener can then update their own sessions UI.

You will need to use the @Push annotation on your UI so that server side updates are pushed to the browser.

Hope that makes some sense.

You may find this thread useful:

https://vaadin.com/forum/thread/4544126/eventbus-for-vaadin

I just found this article which is pretty much exactly what you need:

https://vaadin.com/docs/v8/framework/advanced/advanced-push.html