org.bdware.doip.cluster.engine.DoaClientUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of doip-audit-tool Show documentation
Show all versions of doip-audit-tool Show documentation
doip audit tool developed by bdware
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);
}
}