當前位置: 首頁>>代碼示例>>Java>>正文


Java OnRPCResponseListener類代碼示例

本文整理匯總了Java中com.smartdevicelink.proxy.rpc.listeners.OnRPCResponseListener的典型用法代碼示例。如果您正苦於以下問題:Java OnRPCResponseListener類的具體用法?Java OnRPCResponseListener怎麽用?Java OnRPCResponseListener使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


OnRPCResponseListener類屬於com.smartdevicelink.proxy.rpc.listeners包,在下文中一共展示了OnRPCResponseListener類的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onRPCResponseReceived

import com.smartdevicelink.proxy.rpc.listeners.OnRPCResponseListener; //導入依賴的package包/類
/**
 * Will provide callback to the listener either onFinish or onError depending on the RPCResponses result code,
 * <p>Will automatically remove the listener for the list of listeners on completion. 
 * @param msg The RPCResponse message that was received
 * @return if a listener was called or not
 */
@SuppressWarnings("UnusedReturnValue")
private boolean onRPCResponseReceived(RPCResponse msg){
	synchronized(ON_UPDATE_LISTENER_LOCK){
		int correlationId = msg.getCorrelationID();
		if(rpcResponseListeners !=null 
				&& rpcResponseListeners.indexOfKey(correlationId)>=0){
			OnRPCResponseListener listener = rpcResponseListeners.get(correlationId);
			if(msg.getSuccess()){
				listener.onResponse(correlationId, msg);
			}else{
				listener.onError(correlationId, msg.getResultCode(), msg.getInfo());
			}
			rpcResponseListeners.remove(correlationId);
			return true;
		}
		return false;
	}
}
 
開發者ID:smartdevicelink,項目名稱:sdl_android,代碼行數:25,代碼來源:SdlProxyBase.java

示例2: uploadImages

import com.smartdevicelink.proxy.rpc.listeners.OnRPCResponseListener; //導入依賴的package包/類
/**
 *  Requests list of images to SDL, and uploads images that are missing.
 */
private void uploadImages(){
	ListFiles listFiles = new ListFiles();
	listFiles.setOnRPCResponseListener(new OnRPCResponseListener() {
		@Override
		public void onResponse(int correlationId, RPCResponse response) {
			if(response.getSuccess()){
				remoteFiles = ((ListFilesResponse) response).getFilenames();
			}

			// Check the mutable set for the AppIcon
			// If not present, upload the image
			if(remoteFiles== null || !remoteFiles.contains(SdlService.ICON_FILENAME)){
				sendIcon();
			}else{
				// If the file is already present, send the SetAppIcon request
				try {
					proxy.setappicon(ICON_FILENAME, CorrelationIdGenerator.generateId());
				} catch (SdlException e) {
					e.printStackTrace();
				}
			}

			// Check the mutable set for the SDL image
			// If not present, upload the image
			if(remoteFiles== null || !remoteFiles.contains(SdlService.SDL_IMAGE_FILENAME)){
				uploadImage(R.drawable.sdl, SDL_IMAGE_FILENAME, CorrelationIdGenerator.generateId(), true);
			}
		}
	});
	this.sendRpcRequest(listFiles);
}
 
開發者ID:smartdevicelink,項目名稱:hello_sdl_android,代碼行數:35,代碼來源:SdlService.java

示例3: addOnRPCResponseListener

import com.smartdevicelink.proxy.rpc.listeners.OnRPCResponseListener; //導入依賴的package包/類
/**
* Add a listener that will receive the response to the specific RPCRequest sent with the corresponding correlation id
* @param listener that will get called back when a response is received
* @param correlationId of the RPCRequest that was sent
* @param totalSize only include if this is an OnPutFileUpdateListener. Otherwise it will be ignored.
*/
public void addOnRPCResponseListener(OnRPCResponseListener listener,int correlationId, int totalSize){
	synchronized(ON_UPDATE_LISTENER_LOCK){
		if(rpcResponseListeners!=null 
				&& listener !=null){
			if(listener.getListenerType() == OnRPCResponseListener.UPDATE_LISTENER_TYPE_PUT_FILE){
				((OnPutFileUpdateListener)listener).setTotalSize(totalSize);
			}
			listener.onStart(correlationId);
			rpcResponseListeners.put(correlationId, listener);
		}
	}
}
 
開發者ID:smartdevicelink,項目名稱:sdl_android,代碼行數:19,代碼來源:SdlProxyBase.java

示例4: sendRPCRequestPrivate

import com.smartdevicelink.proxy.rpc.listeners.OnRPCResponseListener; //導入依賴的package包/類
/************* END Functions used by the Message Dispatching Queues ****************/

// Private sendPRCRequest method. All RPCRequests are funneled through this method after
	// error checking. 
private void sendRPCRequestPrivate(RPCRequest request) throws SdlException {
		try {
		SdlTrace.logRPCEvent(InterfaceActivityDirection.Transmit, request, SDL_LIB_TRACE_KEY);
					
		byte[] msgBytes = JsonRPCMarshaller.marshall(request, _wiproVersion);

		ProtocolMessage pm = new ProtocolMessage();
		pm.setData(msgBytes);
		if (sdlSession != null)
			pm.setSessionID(sdlSession.getSessionId());
		pm.setMessageType(MessageType.RPC);
		pm.setSessionType(SessionType.RPC);
		pm.setFunctionID(FunctionID.getFunctionId(request.getFunctionName()));
		pm.setPayloadProtected(request.isPayloadProtected());
		if (request.getCorrelationID() == null)
		{
			//Log error here
			throw new SdlException("CorrelationID cannot be null. RPC: " + request.getFunctionName(), SdlExceptionCause.INVALID_ARGUMENT);
		}
		pm.setCorrID(request.getCorrelationID());
		if (request.getBulkData() != null){
			pm.setBulkData(request.getBulkData());
		}
		if(request.getFunctionName().equalsIgnoreCase(FunctionID.PUT_FILE.name())){
			pm.setPriorityCoefficient(1);
		}
		
		// Queue this outgoing message
		synchronized(OUTGOING_MESSAGE_QUEUE_THREAD_LOCK) {
			if (_outgoingProxyMessageDispatcher != null) {
				_outgoingProxyMessageDispatcher.queueMessage(pm);
				//Since the message is queued we can add it's listener to our list
				OnRPCResponseListener listener = request.getOnRPCResponseListener();
				if(request.getMessageType().equals(RPCMessage.KEY_REQUEST)){//We might want to include other message types in the future
					addOnRPCResponseListener(listener, request.getCorrelationID(), msgBytes.length);
				}
			}
		}
	} catch (OutOfMemoryError e) {
		SdlTrace.logProxyEvent("OutOfMemory exception while sending request " + request.getFunctionName(), SDL_LIB_TRACE_KEY);
		throw new SdlException("OutOfMemory exception while sending request " + request.getFunctionName(), e, SdlExceptionCause.INVALID_ARGUMENT);
	}
}
 
開發者ID:smartdevicelink,項目名稱:sdl_android,代碼行數:48,代碼來源:SdlProxyBase.java

示例5: getResponseListeners

import com.smartdevicelink.proxy.rpc.listeners.OnRPCResponseListener; //導入依賴的package包/類
@SuppressWarnings("unused")
public SparseArray<OnRPCResponseListener> getResponseListeners(){
	synchronized(ON_UPDATE_LISTENER_LOCK){
		return this.rpcResponseListeners;
	}
}
 
開發者ID:smartdevicelink,項目名稱:sdl_android,代碼行數:7,代碼來源:SdlProxyBase.java

示例6: setOnRPCResponseListener

import com.smartdevicelink.proxy.rpc.listeners.OnRPCResponseListener; //導入依賴的package包/類
@Override
public final void setOnRPCResponseListener(OnRPCResponseListener listener) {
	super.setOnRPCResponseListener(listener);
}
 
開發者ID:smartdevicelink,項目名稱:sdl_android,代碼行數:5,代碼來源:PutFile.java

示例7: setOnRPCResponseListener

import com.smartdevicelink.proxy.rpc.listeners.OnRPCResponseListener; //導入依賴的package包/類
public void setOnRPCResponseListener(OnRPCResponseListener listener){
	onResponseListener = listener;
}
 
開發者ID:smartdevicelink,項目名稱:sdl_android,代碼行數:4,代碼來源:RPCRequest.java

示例8: getOnRPCResponseListener

import com.smartdevicelink.proxy.rpc.listeners.OnRPCResponseListener; //導入依賴的package包/類
public OnRPCResponseListener getOnRPCResponseListener(){
	return this.onResponseListener;
}
 
開發者ID:smartdevicelink,項目名稱:sdl_android,代碼行數:4,代碼來源:RPCRequest.java


注:本文中的com.smartdevicelink.proxy.rpc.listeners.OnRPCResponseListener類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。