*/
public final String data;
+ /** The ID of this request. Used in annotations. Can be null */
+ public final transient String requestId;
+
/**
* Construct an Address from its parts
*
public Address(final Protocol protocol, final @Nullable String data){
this.protocol=protocol;
this.data=data;
+ this.requestId=null;
+ }
+
+ /**
+ * Construct an Address from its parts
+ *
+ * @param protocol the protocol part of the Address
+ * @param data the data part of the Address
+ * @param requestId the request ID
+ */
+ public Address(final Protocol protocol, final @Nullable String data, final String requestId){
+ this.protocol=protocol;
+ this.data=data;
+ this.requestId=requestId;
}
/**
final String[] parts=address.split(" ", 2);
this.protocol=Protocol.valueOf(parts[0]);
this.data=parts[1];
+ this.requestId=null;
}
/**
final JSONArray jsonargs=object.getJSONArray("args");
final String command=object.getString("command");
- final Address replyTo=new Address(toNonNull(Protocol.HTTP), object.getString("replyto"));//NOPMD address depends on command
+ final Address replyTo=new Address(toNonNull(Protocol.HTTP), object.getString("replyto"), object.has("requestid") ? object.getString("requestid") : null);//NOPMD address depends on command
final String[] args=new String[jsonargs.length()];
for(int j=0;j<args.length;j++)
args[j]=jsonargs.getString(j);
public static void sendMessage(final Context context, final Address address, final String message){
switch(address.protocol){
case HTTP:
- new HttpCallExecutableRunnable("/send", toNonNull(Arrays.asList(
- new Header("X-Destination", toNonNull(address.data)))), context, null, true, message).execute();
+ new HttpCallExecutableRunnable("/send", toNonNull(Arrays.asList(new Header("X-Destination", toNonNull(address.data)))), context, null, true, address.requestId == null ? message : address.requestId + " " + message).execute();
break;
case SMS: