summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBretty White <geekman3454@protonmail.com>2018-07-11 16:11:32 -0400
committerBretty White <geekman3454@protonmail.com>2018-07-11 16:11:32 -0400
commit7ee7df8a465f34e0503936d4555f579215cebdf1 (patch)
tree15ddb56739e03203b14be93435a1be3b95eaf541
parent41b0e6f5314d4b28747fd64e980fbcbe14ca575c (diff)
downloadsdl_android-7ee7df8a465f34e0503936d4555f579215cebdf1.tar.gz
changed sending methods to accept RPCMessage, added docs to those methods
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/api/SdlManager.java67
1 files changed, 61 insertions, 6 deletions
diff --git a/sdl_android/src/main/java/com/smartdevicelink/api/SdlManager.java b/sdl_android/src/main/java/com/smartdevicelink/api/SdlManager.java
index 3f36a595f..5ca20d52a 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/api/SdlManager.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/api/SdlManager.java
@@ -6,6 +6,7 @@ import android.support.annotation.NonNull;
import com.smartdevicelink.exception.SdlException;
import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.protocol.enums.SessionType;
+import com.smartdevicelink.proxy.RPCMessage;
import com.smartdevicelink.proxy.RPCRequest;
import com.smartdevicelink.proxy.SdlProxyBase;
import com.smartdevicelink.proxy.callbacks.OnServiceEnded;
@@ -29,6 +30,7 @@ import com.smartdevicelink.streaming.audio.AudioStreamingParams;
import com.smartdevicelink.streaming.video.VideoStreamingParameters;
import com.smartdevicelink.transport.BaseTransportConfig;
+import java.util.ArrayList;
import java.util.List;
import java.util.Vector;
@@ -284,16 +286,69 @@ public class SdlManager implements ProxyBridge.LifecycleListener {
// SENDING REQUESTS
- public void sendRPC(RPCRequest request) throws SdlException {
- proxy.sendRPCRequest(request);
+ /**
+ * Send RPC Message <br>
+ * <strong>Note: Only takes type of RPCRequest for now, notifications and responses will be thrown out</strong>
+ * @param message RPCMessage
+ * @throws SdlException
+ */
+ public void sendRPC(RPCMessage message) throws SdlException {
+
+ if (message instanceof RPCRequest){
+ proxy.sendRPCRequest((RPCRequest)message);
+ }
}
- public void sendSequentialRPCs(final List<? extends RPCRequest> rpcs, final OnMultipleRequestListener listener) throws SdlException {
- proxy.sendSequentialRequests(rpcs, listener);
+ /**
+ * Takes a list of RPCMessages and sends it to SDL in a synchronous fashion. Responses are captured through callback on OnMultipleRequestListener.
+ * For sending requests asynchronously, use sendRequests <br>
+ *
+ * <strong>NOTE: This will override any listeners on individual RPCs</strong><br>
+ *
+ * <strong>ADDITIONAL NOTE: This only takes the type of RPCRequest for now, notifications and responses will be thrown out</strong>
+ *
+ * @param rpcs is the list of RPCMessages being sent
+ * @param listener listener for updates and completions
+ * @throws SdlException if an unrecoverable error is encountered
+ */
+ public void sendSequentialRPCs(final List<? extends RPCMessage> rpcs, final OnMultipleRequestListener listener) throws SdlException {
+
+ List<RPCRequest> rpcRequestList = new ArrayList<>();
+ for (int i = 0; i < rpcs.size(); i++) {
+ if (rpcs.get(i) instanceof RPCRequest){
+ rpcRequestList.add((RPCRequest)rpcs.get(i));
+ }
+ }
+
+ if (rpcRequestList.size() > 0) {
+ proxy.sendSequentialRequests(rpcRequestList, listener);
+ }
}
- public void sendRPCs(List<? extends RPCRequest> rpcs, final OnMultipleRequestListener listener) throws SdlException {
- proxy.sendRequests(rpcs, listener);
+ /**
+ * Takes a list of RPCMessages and sends it to SDL. Responses are captured through callback on OnMultipleRequestListener.
+ * For sending requests synchronously, use sendSequentialRPCs <br>
+ *
+ * <strong>NOTE: This will override any listeners on individual RPCs</strong> <br>
+ *
+ * <strong>ADDITIONAL NOTE: This only takes the type of RPCRequest for now, notifications and responses will be thrown out</strong>
+ *
+ * @param rpcs is the list of RPCMessages being sent
+ * @param listener listener for updates and completions
+ * @throws SdlException if an unrecoverable error is encountered
+ */
+ public void sendRPCs(List<? extends RPCMessage> rpcs, final OnMultipleRequestListener listener) throws SdlException {
+
+ List<RPCRequest> rpcRequestList = new ArrayList<>();
+ for (int i = 0; i < rpcs.size(); i++) {
+ if (rpcs.get(i) instanceof RPCRequest){
+ rpcRequestList.add((RPCRequest)rpcs.get(i));
+ }
+ }
+
+ if (rpcRequestList.size() > 0) {
+ proxy.sendRequests(rpcRequestList, listener);
+ }
}
// LIFECYCLE / OTHER