All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.bdware.doip.cluster.engine.DoaClientUtil Maven / Gradle / Ivy

The newest version!
package org.bdware.doip.cluster.engine;

import com.google.gson.JsonObject;
import org.bdware.doip.cluster.client.DoaClusterClient;
import org.bdware.doip.cluster.util.JSONTool;
import org.bdware.doip.codec.JsonDoipMessage;
import org.bdware.doip.codec.doipMessage.DoipMessage;
import org.bdware.doip.endpoint.client.DoipMessageCallback;
import org.bdware.sc.util.JsonUtil;
import wrp.jdk.nashorn.api.scripting.ScriptObjectMirror;

public class DoaClientUtil {
    public DoaClusterClient client;

    public DoaClientUtil(DoaClusterClient client) {
        this.client = client;
    }

    public DoipMessage sendMessageSync(ScriptObjectMirror arg) {
        JsonObject toJson = JSONTool.convertMirrorToJson(arg).getAsJsonObject();
        JsonDoipMessage jsonDoipMessage = JsonUtil.fromJson(toJson, JsonDoipMessage.class);
        DoipMessage doipMessage = jsonDoipMessage.toRequestDoipMessage();
        return client.sendMessageSync(doipMessage, 10000, false);
    }

    public DoipMessage sendMessageSync(DoipMessage doipMessage) {
        return client.sendMessageSync(doipMessage, 10000, false);
    }
    public void sendMessage(DoipMessage arg, DoipMessageCallback callback) {
        client.sendMessage(arg, callback, false);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy