当前位置: 首页>>代码示例>>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;未经允许,请勿转载。