当前位置: 首页>>代码示例>>Java>>正文


Java DiscoveryListener.SERVICE_SEARCH_COMPLETED属性代码示例

本文整理汇总了Java中javax.bluetooth.DiscoveryListener.SERVICE_SEARCH_COMPLETED属性的典型用法代码示例。如果您正苦于以下问题:Java DiscoveryListener.SERVICE_SEARCH_COMPLETED属性的具体用法?Java DiscoveryListener.SERVICE_SEARCH_COMPLETED怎么用?Java DiscoveryListener.SERVICE_SEARCH_COMPLETED使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在javax.bluetooth.DiscoveryListener的用法示例。


在下文中一共展示了DiscoveryListener.SERVICE_SEARCH_COMPLETED属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: serviceSearchResponseCodeToString

private static String serviceSearchResponseCodeToString(int code) {
    if (code == DiscoveryListener.SERVICE_SEARCH_COMPLETED) {
        return "SERVICE_SEARCH_COMPLETED";
    } else if (code == DiscoveryListener.SERVICE_SEARCH_DEVICE_NOT_REACHABLE) {
        return "SERVICE_SEARCH_DEVICE_NOT_REACHABLE";
    } else if (code == DiscoveryListener.SERVICE_SEARCH_ERROR) {
        return "SERVICE_SEARCH_ERROR";
    } else if (code == DiscoveryListener.SERVICE_SEARCH_NO_RECORDS) {
        return "SERVICE_SEARCH_NO_RECORDS";
    } else if (code == DiscoveryListener.SERVICE_SEARCH_TERMINATED) {
        return "SERVICE_SEARCH_TERMINATED";
    } else {
        return "Unknown";
    }
}
 
开发者ID:Blaubot,项目名称:Blaubot,代码行数:15,代码来源:BlaubotJsr82BluetoothConnector.java

示例2: serviceSearchCompleted

/**
 * 
 * This method is called by the javax.bluetooth.DiscoveryAgent (agent) when the search for services (read: Peer2Me framework) is completed
 * 
 * @param transID The transaction ID of the service search that is posting the result
 * @param respCode The response code that indicates the status of the transaction
 * 
 */
public void serviceSearchCompleted(int transID, int respCode){
	        
	switch(respCode) {
		
		case DiscoveryListener.SERVICE_SEARCH_COMPLETED:
 		log.logDebugInfo("BluetoothServiceDiscovery.serviceSearchCompleted()","Service search completed");
	    break;
                
		case DiscoveryListener.SERVICE_SEARCH_DEVICE_NOT_REACHABLE:        	
			log.logDebugInfo("BluetoothServiceDiscovery.serviceSearchCompleted()","Service search device not reachable");
			// If a searchServices() call is made on a specific device, the devices found table will contain no devices
 		// In this case the network must be notified about the error.
 		// In the initial doDeviceDiscovery() these errors are ignored because devices not running the framework can interfere the discovery process.
 		if(devicesFound.size()==0) currentNetwork.serviceDiscoveryError();
    	break;
                
		case DiscoveryListener.SERVICE_SEARCH_ERROR:
			log.logDebugInfo("BluetoothServiceDiscovery.serviceSearchCompleted()","Service search error");
 		if(devicesFound.size()==0) currentNetwork.serviceDiscoveryError();
		break;
                
		case DiscoveryListener.SERVICE_SEARCH_NO_RECORDS:
			log.logDebugInfo("BluetoothServiceDiscovery.serviceSearchCompleted()","No bluetooth devices running the same service (application) found");
 		if(devicesFound.size()==0) currentNetwork.serviceDiscoveryError();
    	break;
                
        case DiscoveryListener.SERVICE_SEARCH_TERMINATED:
        	log.logDebugInfo("BluetoothServiceDiscovery.serviceSearchCompleted()","Service search terminated");
 		if(devicesFound.size()==0) currentNetwork.serviceDiscoveryError();
		break;
	}

	// Searches further on the next device
	if(devicesFound.size()>0){                        
		try {
			// The discovery agent searches for services on the next device stored in the devicesFound Vector
			agent.searchServices(attributes,uuids,(RemoteDevice)devicesFound.firstElement(),this);
			devicesFound.removeElementAt(0);
		} catch (BluetoothStateException bse) {
			log.logException("BluetoothServiceDiscovery.serviceSearchCompleted", bse, true);
			currentNetwork.serviceDiscoveryError();
		}	    	    		
	}
	
	else{	    	    		
		if(servicesFound.size()==0){
			log.logDebugInfo("BluetoothServiceDiscovery.serviceSearchCompleted()","No services found");	    	    			
		}else{
            log.logDebugInfo("BluetoothServiceDiscovery.serviceSearchCompleted()","Found the desired service running on one or more nodes");
			// For each element in servicesFound the serviceFound method is called on currentNetwork     
            for(int i=0;i<servicesFound.size();i++){
            	currentNetwork.nodeFound((ServiceRecord)servicesFound.elementAt(i));
			}
			currentNetwork.serviceSearchCompleted();
		}                        
	}

}
 
开发者ID:meisamhe,项目名称:GPLshared,代码行数:66,代码来源:BluetoothServiceDiscovery.java

示例3: notifyListener

private void notifyListener(int respCode) {
    // guard against multiple notification calls
    synchronized (this) {
        if (!notified) {
            notified = true;
        } else {
            return;
        }
    }

    if (DEBUG) {
        String codeStr = "Undefined";

        switch (respCode) {
        case DiscoveryListener.SERVICE_SEARCH_COMPLETED:
            codeStr = "SERVICE_SEARCH_COMPLETED";
            break;

        case DiscoveryListener.SERVICE_SEARCH_DEVICE_NOT_REACHABLE:
            codeStr = "SERVICE_SEARCH_DEVICE_NOT_REACHABLE";
            break;

        case DiscoveryListener.SERVICE_SEARCH_ERROR:
            codeStr = "SERVICE_SEARCH_ERROR";
            break;

        case DiscoveryListener.SERVICE_SEARCH_NO_RECORDS:
            codeStr = "SERVICE_SEARCH_NO_RECORDS";
            break;

        case DiscoveryListener.SERVICE_SEARCH_TERMINATED:
            codeStr = "SERVICE_SEARCH_TERMINATED";
            break;
        default:
        }
        if (DEBUG) {
            System.out.println("serviceSearchCompleted:");
            System.out.println("\ttransID=" + transactionID);
            System.out.println("\trespCode=" + codeStr);
            System.out.println("\tinactive=" + inactive);
        }
    }

    try {
        discListener.serviceSearchCompleted(transactionID, respCode);
    } catch (Throwable e) {
        e.printStackTrace();
    }
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:49,代码来源:ServiceSearcher.java


注:本文中的javax.bluetooth.DiscoveryListener.SERVICE_SEARCH_COMPLETED属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。