RPC Calls Javascript And Concurrency

Hello everyone,

I’m a beginner with Vaadin and Java, and I’m trying to do a little visualizer with BabylonJs.
To achieve this I’m developing my component extending the AbstractJavaScriptComponent.
So I want to call some functions of BabylonJS from the server, and doing some stuff with the returned object.

The babylonJs objects have a unique ID which allow me to do things on the server with my own classes (Mesh, Camera, Light,…), and with RPC calls, passing these IDs in parameters to achieve things on client side.

But when I want a returned object from a java method, the time the RPC call is done, I have an object but his propertys are set after I returned it. I know, I’m not a good in explanations. Here is an Example :

This is a quick preview of the code
Server Side :

public class Viz3D extends AbstractJavaScriptComponent {

private PickingInfo pickInfo;

public Viz3D() {
    Viz3D instance = this;
    addFunction("setPickingInfo", new  JavaScriptFunction() {
        public void call(elemental.json.JsonArray arguments) {
            PickingInfo pick = new PickingInfo();
            int param = 0;
            Boolean hit = arguments.getBoolean(param);
            if (hit) {
                float distance = (float) arguments.getNumber(param);
                Vector3f pickedPoint = new Vector3f((float) arguments.getNumber(param),
                        (float) arguments.getNumber(param + 1), (float) arguments.getNumber(param + 2));
                param += 3;
                String meshName = arguments.getString(param);
                int bu = (int) arguments.getNumber(param), bv = (int) arguments.getNumber(param + 1);
                param += 2;
                int faceId = (int) arguments.getNumber(param), subMeshId = (int) arguments.getNumber(param + 1);
                param += 2;
            pickInfo = pick;
public Future<PickingInfo> pick(int x, int y) {
    callFunction("pickScene", x, y);
    return pickInfo;

[/code]Client Side :

// The function called by the server, sending him the result of the function scene.pick // Scene is my scene in babylonJs connector.pickScene = function(x, y) { var pickInfo = scene.pick(scene.pointerX, scene.pointerY); window.connector.setPickingInfo(pickInfo.hit, pickInfo.distance, pickInfo.pickedPoint.x, pickInfo.pickedPoint.y, pickInfo.pickedPoint.z, pickInfo.pickedMesh.name, pickInfo.bu, pickInfo.bv, pickInfo.faceId, pickInfo.subMeshId); }; This code is supposed to get the information of a component in babylon and send these to the server. But when i click the first time on something it returns nothing and the second time it returns the info of the previous click, etc…

Is there a way to block the server side, and wait for the rpc call being finished ? (I tried some asynchronous things but didn’t end well)

Thank you for your time, and sorry for the bad english too :slight_smile: