mirror of
https://github.com/AsamK/signal-cli
synced 2025-09-02 04:20:38 +00:00
renamed jsonEvtLoop -> jsonEventLoop
This commit is contained in:
parent
8b36f35d23
commit
28472cbd60
4 changed files with 51 additions and 51 deletions
|
@ -18,20 +18,20 @@ import org.whispersystems.signalservice.api.messages.SignalServiceEnvelope;
|
||||||
|
|
||||||
//import java.io.IOException;
|
//import java.io.IOException;
|
||||||
|
|
||||||
public class JsonEvtLoopReceiveMessageHandler implements Manager.ReceiveMessageHandler {
|
public class JsonEventLoopReceiveMessageHandler implements Manager.ReceiveMessageHandler {
|
||||||
|
|
||||||
public interface ResponseEmitter {
|
public interface ResponseEmitter {
|
||||||
public void emit( JsonEvtLoopStatusReport resp);
|
public void emit( JsonEventLoopStatusReport resp);
|
||||||
}
|
}
|
||||||
|
|
||||||
final Manager m;
|
final Manager m;
|
||||||
ResponseEmitter responseEmitter;
|
ResponseEmitter responseEmitter;
|
||||||
|
|
||||||
public JsonEvtLoopReceiveMessageHandler(Manager m) {
|
public JsonEventLoopReceiveMessageHandler(Manager m) {
|
||||||
this.m = m;
|
this.m = m;
|
||||||
}
|
}
|
||||||
|
|
||||||
public JsonEvtLoopReceiveMessageHandler( Manager m, ResponseEmitter responseEmitter) {
|
public JsonEventLoopReceiveMessageHandler( Manager m, ResponseEmitter responseEmitter) {
|
||||||
this.m = m;
|
this.m = m;
|
||||||
this.responseEmitter = responseEmitter;
|
this.responseEmitter = responseEmitter;
|
||||||
}
|
}
|
||||||
|
@ -39,17 +39,17 @@ public class JsonEvtLoopReceiveMessageHandler implements Manager.ReceiveMessageH
|
||||||
@Override
|
@Override
|
||||||
public void handleMessage(SignalServiceEnvelope envelope, SignalServiceContent content, Throwable exception) {
|
public void handleMessage(SignalServiceEnvelope envelope, SignalServiceContent content, Throwable exception) {
|
||||||
//ObjectNode result = jsonProcessor.createObjectNode();
|
//ObjectNode result = jsonProcessor.createObjectNode();
|
||||||
JsonEvtLoopStatusReport resp = null;
|
JsonEventLoopStatusReport resp = null;
|
||||||
if (exception != null) {
|
if (exception != null) {
|
||||||
resp = new JsonEvtLoopStatusReport( "error", null, "error", "JsonEvtLoopReceiveMessageHandler::handleMessage: Exception: " + exception.toString());
|
resp = new JsonEventLoopStatusReport( "error", null, "error", "JsonEventLoopReceiveMessageHandler::handleMessage: Exception: " + exception.toString());
|
||||||
//result.putPOJO("error", new JsonError(exception));
|
//result.putPOJO("error", new JsonError(exception));
|
||||||
}
|
}
|
||||||
if (envelope != null) {
|
if (envelope != null) {
|
||||||
//result.putPOJO("envelope", new JsonMessageEnvelope(envelope, content));
|
//result.putPOJO("envelope", new JsonMessageEnvelope(envelope, content));
|
||||||
resp = new JsonEvtLoopStatusReport( new JsonMessageEnvelope(envelope, content));
|
resp = new JsonEventLoopStatusReport( new JsonMessageEnvelope(envelope, content));
|
||||||
}
|
}
|
||||||
if(resp == null) {
|
if(resp == null) {
|
||||||
new JsonEvtLoopStatusReport( "error", null, "JsonEvtLoopReceiveMessageHandler::handleMessage: both exceptino and envelope is null!").emit();
|
new JsonEventLoopStatusReport( "error", null, "JsonEventLoopReceiveMessageHandler::handleMessage: both exceptino and envelope is null!").emit();
|
||||||
} else {
|
} else {
|
||||||
if( this.responseEmitter != null) {
|
if( this.responseEmitter != null) {
|
||||||
this.responseEmitter.emit( resp);
|
this.responseEmitter.emit( resp);
|
|
@ -11,7 +11,7 @@ public class Commands {
|
||||||
addCommand("addDevice", new AddDeviceCommand());
|
addCommand("addDevice", new AddDeviceCommand());
|
||||||
addCommand("block", new BlockCommand());
|
addCommand("block", new BlockCommand());
|
||||||
addCommand("daemon", new DaemonCommand());
|
addCommand("daemon", new DaemonCommand());
|
||||||
addCommand("jsonevtloop", new JsonEvtLoopCommand());
|
addCommand("jsonEventLoop", new JsonEventLoopCommand());
|
||||||
addCommand("link", new LinkCommand());
|
addCommand("link", new LinkCommand());
|
||||||
addCommand("listContacts", new ListContactsCommand());
|
addCommand("listContacts", new ListContactsCommand());
|
||||||
addCommand("listDevices", new ListDevicesCommand());
|
addCommand("listDevices", new ListDevicesCommand());
|
||||||
|
|
|
@ -6,7 +6,7 @@ import net.sourceforge.argparse4j.inf.Subparser;
|
||||||
|
|
||||||
import org.asamk.Signal;
|
import org.asamk.Signal;
|
||||||
import org.asamk.signal.GroupIdFormatException;
|
import org.asamk.signal.GroupIdFormatException;
|
||||||
import org.asamk.signal.JsonEvtLoopReceiveMessageHandler;
|
import org.asamk.signal.JsonEventLoopReceiveMessageHandler;
|
||||||
import org.asamk.signal.JsonReceiveMessageHandler;
|
import org.asamk.signal.JsonReceiveMessageHandler;
|
||||||
import org.asamk.signal.manager.Manager;
|
import org.asamk.signal.manager.Manager;
|
||||||
import org.asamk.signal.storage.contacts.ContactInfo;
|
import org.asamk.signal.storage.contacts.ContactInfo;
|
||||||
|
@ -29,7 +29,7 @@ import static org.asamk.signal.util.ErrorUtils.handleAssertionError;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public class JsonEvtLoopCommand implements LocalCommand {
|
public class JsonEventLoopCommand implements LocalCommand {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -38,14 +38,14 @@ public class JsonEvtLoopCommand implements LocalCommand {
|
||||||
* @author bingel
|
* @author bingel
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static class JsonEvtLoopRequestHandler {
|
private static class JsonEventLoopRequestHandler {
|
||||||
Manager m;
|
Manager m;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
* @param m Signal Manager object
|
* @param m Signal Manager object
|
||||||
*/
|
*/
|
||||||
JsonEvtLoopRequestHandler( Manager m) {
|
JsonEventLoopRequestHandler( Manager m) {
|
||||||
this.m = m;
|
this.m = m;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,28 +55,28 @@ public class JsonEvtLoopCommand implements LocalCommand {
|
||||||
* @param reqID
|
* @param reqID
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
JsonEvtLoopStatusReport list_groups( JsonNode reqObj, JsonNode reqID) {
|
JsonEventLoopStatusReport list_groups( JsonNode reqObj, JsonNode reqID) {
|
||||||
List<GroupInfo> groups = m.getGroups();
|
List<GroupInfo> groups = m.getGroups();
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
JsonNode data_obj = mapper.valueToTree(groups);
|
JsonNode data_obj = mapper.valueToTree(groups);
|
||||||
return new JsonEvtLoopStatusReport( "group_list", reqID, data_obj);
|
return new JsonEventLoopStatusReport( "group_list", reqID, data_obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Command Handler: list_contacts
|
* Command Handler: list_contacts
|
||||||
*/
|
*/
|
||||||
JsonEvtLoopStatusReport list_contacts( JsonNode reqObj, JsonNode reqID) {
|
JsonEventLoopStatusReport list_contacts( JsonNode reqObj, JsonNode reqID) {
|
||||||
List<ContactInfo> contacts = m.getContacts();
|
List<ContactInfo> contacts = m.getContacts();
|
||||||
ObjectMapper mpr = new ObjectMapper();
|
ObjectMapper mpr = new ObjectMapper();
|
||||||
JsonNode data_obj = mpr.valueToTree(contacts);
|
JsonNode data_obj = mpr.valueToTree(contacts);
|
||||||
return new JsonEvtLoopStatusReport( "contact_list", reqID, data_obj);
|
return new JsonEventLoopStatusReport( "contact_list", reqID, data_obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Command Handler: Send signal message and respond with status message
|
* Command Handler: Send signal message and respond with status message
|
||||||
* @param reqObj JSON parsed request object
|
* @param reqObj JSON parsed request object
|
||||||
*/
|
*/
|
||||||
JsonEvtLoopStatusReport send_message( JsonNode reqObj, JsonNode reqID) {
|
JsonEventLoopStatusReport send_message( JsonNode reqObj, JsonNode reqID) {
|
||||||
|
|
||||||
// get body text
|
// get body text
|
||||||
String body_text = null;
|
String body_text = null;
|
||||||
|
@ -98,9 +98,9 @@ public class JsonEvtLoopCommand implements LocalCommand {
|
||||||
try {
|
try {
|
||||||
m.sendMessage( body_text, attachments, recipientNumber);
|
m.sendMessage( body_text, attachments, recipientNumber);
|
||||||
} catch( IOException e) {
|
} catch( IOException e) {
|
||||||
return new JsonEvtLoopStatusReport( "send_message", reqID, "error", "IOException: " + e.toString() );
|
return new JsonEventLoopStatusReport( "send_message", reqID, "error", "IOException: " + e.toString() );
|
||||||
} catch( EncapsulatedExceptions e) {
|
} catch( EncapsulatedExceptions e) {
|
||||||
return new JsonEvtLoopStatusReport( "send_message", reqID, "error", "EncapsulatedException: " + e.toString() );
|
return new JsonEventLoopStatusReport( "send_message", reqID, "error", "EncapsulatedException: " + e.toString() );
|
||||||
}
|
}
|
||||||
} else if( reqObj.get("recipientGroupID") != null) {
|
} else if( reqObj.get("recipientGroupID") != null) {
|
||||||
// send message to group
|
// send message to group
|
||||||
|
@ -109,17 +109,17 @@ public class JsonEvtLoopCommand implements LocalCommand {
|
||||||
byte[] recipientGroupID_bytearray = Util.decodeGroupId(recipientGroupID);
|
byte[] recipientGroupID_bytearray = Util.decodeGroupId(recipientGroupID);
|
||||||
m.sendGroupMessage( body_text, attachments, recipientGroupID_bytearray);
|
m.sendGroupMessage( body_text, attachments, recipientGroupID_bytearray);
|
||||||
} catch( GroupIdFormatException e) {
|
} catch( GroupIdFormatException e) {
|
||||||
return new JsonEvtLoopStatusReport( "send_message", reqID, "error", "GroupIdFormatException: " + e.toString() );
|
return new JsonEventLoopStatusReport( "send_message", reqID, "error", "GroupIdFormatException: " + e.toString() );
|
||||||
} catch( IOException e) {
|
} catch( IOException e) {
|
||||||
return new JsonEvtLoopStatusReport( "send_message", reqID, "error", "IOException: " + e.toString() );
|
return new JsonEventLoopStatusReport( "send_message", reqID, "error", "IOException: " + e.toString() );
|
||||||
} catch( EncapsulatedExceptions e) {
|
} catch( EncapsulatedExceptions e) {
|
||||||
return new JsonEvtLoopStatusReport( "send_message", reqID, "error", "EncapsulatedException: " + e.toString() );
|
return new JsonEventLoopStatusReport( "send_message", reqID, "error", "EncapsulatedException: " + e.toString() );
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return new JsonEvtLoopStatusReport( "send_message", reqID, "error", "Neither recipientNumber or recipientGroupID present in request, nothing to do");
|
return new JsonEventLoopStatusReport( "send_message", reqID, "error", "Neither recipientNumber or recipientGroupID present in request, nothing to do");
|
||||||
}
|
}
|
||||||
|
|
||||||
return new JsonEvtLoopStatusReport("send_message", reqID, "ok");
|
return new JsonEventLoopStatusReport("send_message", reqID, "ok");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -129,7 +129,7 @@ public class JsonEvtLoopCommand implements LocalCommand {
|
||||||
void handle( String textRow) {
|
void handle( String textRow) {
|
||||||
//System.err.println( "JsonRequestHandler: incoming string: " + textRow);
|
//System.err.println( "JsonRequestHandler: incoming string: " + textRow);
|
||||||
|
|
||||||
JsonEvtLoopStatusReport resp = null;
|
JsonEventLoopStatusReport resp = null;
|
||||||
boolean exitNow = false;
|
boolean exitNow = false;
|
||||||
try {
|
try {
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
@ -140,10 +140,10 @@ public class JsonEvtLoopCommand implements LocalCommand {
|
||||||
JsonNode reqID = reqObj.get("reqID");
|
JsonNode reqID = reqObj.get("reqID");
|
||||||
switch(reqType) {
|
switch(reqType) {
|
||||||
case "alive":
|
case "alive":
|
||||||
resp = new JsonEvtLoopStatusReport("alive", reqID, "ok");
|
resp = new JsonEventLoopStatusReport("alive", reqID, "ok");
|
||||||
break;
|
break;
|
||||||
case "exit":
|
case "exit":
|
||||||
resp = new JsonEvtLoopStatusReport("exit", reqID, "ok");
|
resp = new JsonEventLoopStatusReport("exit", reqID, "ok");
|
||||||
//System.exit(0);
|
//System.exit(0);
|
||||||
exitNow = true;
|
exitNow = true;
|
||||||
break;
|
break;
|
||||||
|
@ -157,20 +157,20 @@ public class JsonEvtLoopCommand implements LocalCommand {
|
||||||
resp = this.list_contacts( reqObj, reqID);
|
resp = this.list_contacts( reqObj, reqID);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
resp = new JsonEvtLoopStatusReport("error", reqID, "error", "Unknown reqType '" + reqType + "'");
|
resp = new JsonEventLoopStatusReport("error", reqID, "error", "Unknown reqType '" + reqType + "'");
|
||||||
System.err.println("JsonEvtRequestHandler: ERROR: Unknown reqType '" + reqType + "'");
|
System.err.println("JsonEvtRequestHandler: ERROR: Unknown reqType '" + reqType + "'");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
resp = new JsonEvtLoopStatusReport("error", null, "error", "reqType attribute missing");
|
resp = new JsonEventLoopStatusReport("error", null, "error", "reqType attribute missing");
|
||||||
System.err.println("JsonEvtRequestHandler: ERROR: reqType attribute is missing in request");
|
System.err.println("JsonEvtRequestHandler: ERROR: reqType attribute is missing in request");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
resp = new JsonEvtLoopStatusReport("error", null, "error", "Failed to parse JSON, reqObj is NULL");
|
resp = new JsonEventLoopStatusReport("error", null, "error", "Failed to parse JSON, reqObj is NULL");
|
||||||
System.err.println( "JsonEvtRequestHandler: Failed to parse JSON, reqObj is NULL");
|
System.err.println( "JsonEvtRequestHandler: Failed to parse JSON, reqObj is NULL");
|
||||||
}
|
}
|
||||||
} catch( IOException e) {
|
} catch( IOException e) {
|
||||||
resp = new JsonEvtLoopStatusReport("error", null, "error", "Failed to parse JSON: " + e.toString());
|
resp = new JsonEventLoopStatusReport("error", null, "error", "Failed to parse JSON: " + e.toString());
|
||||||
System.err.println( "JsonEvtRequestHandler: Failed to parse JSON, text='" + textRow + "', IOException: " + e.toString());
|
System.err.println( "JsonEvtRequestHandler: Failed to parse JSON, text='" + textRow + "', IOException: " + e.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,7 +178,7 @@ public class JsonEvtLoopCommand implements LocalCommand {
|
||||||
if(resp != null) {
|
if(resp != null) {
|
||||||
resp.emit();
|
resp.emit();
|
||||||
} else {
|
} else {
|
||||||
System.err.println( "JsonEvtRequestHandler: ERROR: No response!");
|
System.err.println( "JsonEventRequestHandler: ERROR: No response!");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Someone requested we exit the program now
|
// Someone requested we exit the program now
|
||||||
|
@ -194,7 +194,7 @@ public class JsonEvtLoopCommand implements LocalCommand {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static class JsonStdinReader implements Runnable {
|
private static class JsonStdinReader implements Runnable {
|
||||||
JsonEvtLoopRequestHandler jsonEvtLoopRequestHandler = null;
|
JsonEventLoopRequestHandler jsonEventLoopRequestHandler = null;
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
BufferedReader br = new BufferedReader( new InputStreamReader( System.in));
|
BufferedReader br = new BufferedReader( new InputStreamReader( System.in));
|
||||||
|
@ -207,12 +207,12 @@ public class JsonEvtLoopCommand implements LocalCommand {
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
if( line != null && !line.equals(""))
|
if( line != null && !line.equals(""))
|
||||||
this.jsonEvtLoopRequestHandler.handle(line);
|
this.jsonEventLoopRequestHandler.handle(line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public JsonStdinReader( JsonEvtLoopRequestHandler j) {
|
public JsonStdinReader( JsonEventLoopRequestHandler j) {
|
||||||
this.jsonEvtLoopRequestHandler = j;
|
this.jsonEventLoopRequestHandler = j;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -232,12 +232,12 @@ public class JsonEvtLoopCommand implements LocalCommand {
|
||||||
public int handleCommand(final Namespace ns, final Manager m) {
|
public int handleCommand(final Namespace ns, final Manager m) {
|
||||||
if (!m.isRegistered()) {
|
if (!m.isRegistered()) {
|
||||||
//System.err.println("User is not registered.");
|
//System.err.println("User is not registered.");
|
||||||
new JsonEvtLoopStatusReport( "error", null, "error", "JsonEvtLoopCommand::handleCommand: User is not registered, aborting");
|
new JsonEventLoopStatusReport( "error", null, "error", "JsonEventLoopCommand::handleCommand: User is not registered, aborting");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start stdin reader thread
|
// Start stdin reader thread
|
||||||
JsonEvtLoopRequestHandler jhandler = new JsonEvtLoopRequestHandler( m);
|
JsonEventLoopRequestHandler jhandler = new JsonEventLoopRequestHandler( m);
|
||||||
JsonStdinReader reader = new JsonStdinReader( jhandler);
|
JsonStdinReader reader = new JsonStdinReader( jhandler);
|
||||||
Thread jsonStdinReaderThread = new Thread( reader);
|
Thread jsonStdinReaderThread = new Thread( reader);
|
||||||
jsonStdinReaderThread.start();
|
jsonStdinReaderThread.start();
|
||||||
|
@ -245,7 +245,7 @@ public class JsonEvtLoopCommand implements LocalCommand {
|
||||||
// start JsonReceiveMessageHandler and let it run forever
|
// start JsonReceiveMessageHandler and let it run forever
|
||||||
boolean ignoreAttachments = ns.getBoolean("ignore_attachments");
|
boolean ignoreAttachments = ns.getBoolean("ignore_attachments");
|
||||||
try {
|
try {
|
||||||
final Manager.ReceiveMessageHandler handler = new JsonEvtLoopReceiveMessageHandler(m, (resp) -> {
|
final Manager.ReceiveMessageHandler handler = new JsonEventLoopReceiveMessageHandler(m, (resp) -> {
|
||||||
// For future use - utilize this lambda callback to emit responses in correct channel
|
// For future use - utilize this lambda callback to emit responses in correct channel
|
||||||
// if that should not happen to be stdout, but for now, just emit json text to stdout
|
// if that should not happen to be stdout, but for now, just emit json text to stdout
|
||||||
resp.emit();
|
resp.emit();
|
||||||
|
@ -254,7 +254,7 @@ public class JsonEvtLoopCommand implements LocalCommand {
|
||||||
return 0;
|
return 0;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
System.err.println("Error while receiving messages: " + e.getMessage());
|
System.err.println("Error while receiving messages: " + e.getMessage());
|
||||||
new JsonEvtLoopStatusReport( "error", null, "error", "JsonEvtLoopCommand::handleCommand: Error while receiving messages: " + e.getMessage()).emit();
|
new JsonEventLoopStatusReport( "error", null, "error", "JsonEventLoopCommand::handleCommand: Error while receiving messages: " + e.getMessage()).emit();
|
||||||
return 3;
|
return 3;
|
||||||
} catch (AssertionError e) {
|
} catch (AssertionError e) {
|
||||||
handleAssertionError(e);
|
handleAssertionError(e);
|
|
@ -12,7 +12,7 @@ import com.fasterxml.jackson.databind.*;
|
||||||
|
|
||||||
|
|
||||||
@JsonInclude(Include.NON_NULL)
|
@JsonInclude(Include.NON_NULL)
|
||||||
public class JsonEvtLoopStatusReport {
|
public class JsonEventLoopStatusReport {
|
||||||
|
|
||||||
public int apiVer = 2;
|
public int apiVer = 2;
|
||||||
public String respType;
|
public String respType;
|
||||||
|
@ -25,18 +25,18 @@ public class JsonEvtLoopStatusReport {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create new JsonEvtLoopStatusReport object for use for responding signal data envelopes
|
* Create new JsonEventLoopStatusReport object for use for responding signal data envelopes
|
||||||
*
|
*
|
||||||
* @param en Envelope from signal Manager
|
* @param en Envelope from signal Manager
|
||||||
*/
|
*/
|
||||||
public JsonEvtLoopStatusReport( JsonMessageEnvelope en) {
|
public JsonEventLoopStatusReport( JsonMessageEnvelope en) {
|
||||||
this.envelope = en;
|
this.envelope = en;
|
||||||
this.respType = "envelope";
|
this.respType = "envelope";
|
||||||
this.status = "ok";
|
this.status = "ok";
|
||||||
this.reqID = null;
|
this.reqID = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public JsonEvtLoopStatusReport( String respType, JsonNode reqID, JsonNode data) {
|
public JsonEventLoopStatusReport( String respType, JsonNode reqID, JsonNode data) {
|
||||||
this.respType = respType;
|
this.respType = respType;
|
||||||
this.status = "ok";
|
this.status = "ok";
|
||||||
this.reqID = reqID;
|
this.reqID = reqID;
|
||||||
|
@ -44,27 +44,27 @@ public class JsonEvtLoopStatusReport {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates new JsonEvtLoopStatusReport object to use for responding to requests
|
* Creates new JsonEventLoopStatusReport object to use for responding to requests
|
||||||
*
|
*
|
||||||
* @param respType Response type (should correspond to request type somehow)
|
* @param respType Response type (should correspond to request type somehow)
|
||||||
* @param reqID Request ID object as present in the request
|
* @param reqID Request ID object as present in the request
|
||||||
* @param status Status of the operation, should be "ok" or "error"
|
* @param status Status of the operation, should be "ok" or "error"
|
||||||
*/
|
*/
|
||||||
public JsonEvtLoopStatusReport( String respType, JsonNode reqID, String status) {
|
public JsonEventLoopStatusReport( String respType, JsonNode reqID, String status) {
|
||||||
this.respType = respType;
|
this.respType = respType;
|
||||||
this.reqID = reqID;
|
this.reqID = reqID;
|
||||||
this.status = status;
|
this.status = status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates new JsonEvtLoopStatusReport object to use for responding to requests
|
* Creates new JsonEventLoopStatusReport object to use for responding to requests
|
||||||
*
|
*
|
||||||
* @param respType Response type (should correspond to request type somehow)
|
* @param respType Response type (should correspond to request type somehow)
|
||||||
* @param reqID Request ID object as present in the request
|
* @param reqID Request ID object as present in the request
|
||||||
* @param status Status of the operation, should be "ok" or "error"
|
* @param status Status of the operation, should be "ok" or "error"
|
||||||
* @param message Message explaining what went wrong in case of status="error"
|
* @param message Message explaining what went wrong in case of status="error"
|
||||||
*/
|
*/
|
||||||
public JsonEvtLoopStatusReport( String respType, JsonNode reqID, String status, String message) {
|
public JsonEventLoopStatusReport( String respType, JsonNode reqID, String status, String message) {
|
||||||
this.respType = respType;
|
this.respType = respType;
|
||||||
this.reqID = reqID;
|
this.reqID = reqID;
|
||||||
this.status = status;
|
this.status = status;
|
||||||
|
@ -82,9 +82,9 @@ public class JsonEvtLoopStatusReport {
|
||||||
JsonNode n = mpr.valueToTree(this);
|
JsonNode n = mpr.valueToTree(this);
|
||||||
System.out.println( mpr.writeValueAsString(n));
|
System.out.println( mpr.writeValueAsString(n));
|
||||||
} catch( IllegalArgumentException e) {
|
} catch( IllegalArgumentException e) {
|
||||||
System.err.println( "JsonEvtLoopStatusReport: ERROR: Failed to serialize object: " + e.toString());
|
System.err.println( "JsonEventLoopStatusReport: ERROR: Failed to serialize object: " + e.toString());
|
||||||
} catch( JsonProcessingException e) {
|
} catch( JsonProcessingException e) {
|
||||||
System.err.println( "JsonEvtLoopStatusReport: ERROR: Failed to serialize object: " + e.toString());
|
System.err.println( "JsonEventLoopStatusReport: ERROR: Failed to serialize object: " + e.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue