本文整理汇总了Java中com.peak.salut.Callbacks.SalutCallback.call方法的典型用法代码示例。如果您正苦于以下问题:Java SalutCallback.call方法的具体用法?Java SalutCallback.call怎么用?Java SalutCallback.call使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.peak.salut.Callbacks.SalutCallback
的用法示例。
在下文中一共展示了SalutCallback.call方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: unregisterClient
import com.peak.salut.Callbacks.SalutCallback; //导入方法依赖的package包/类
public void unregisterClient(@Nullable SalutCallback onSuccess, @Nullable SalutCallback onFailure, boolean disableWiFi) {
BackgroundClientRegistrationJob.onUnregisterSuccess = onSuccess;
BackgroundClientRegistrationJob.onUnregisterFailure = onFailure;
BackgroundClientRegistrationJob.disableWiFiOnUnregister = disableWiFi;
if (receiverRegistered) {
dataReceiver.context.unregisterReceiver(receiver);
receiverRegistered = false;
}
if (!isConnectedToAnotherDevice) {
Log.d(TAG, "Attempted to unregister, but not connected to group. The remote service may already have shutdown.");
thisDevice.isRegistered = false;
registeredHost = null;
closeDataSocket();
disconnectFromDevice();
if (onSuccess != null) {
onSuccess.call();
}
} else {
startRegistrationForClient(new InetSocketAddress(registeredHost.serviceAddress, SALUT_SERVER_PORT));
}
}
示例2: unregisterClient
import com.peak.salut.Callbacks.SalutCallback; //导入方法依赖的package包/类
public void unregisterClient(@Nullable SalutCallback onSuccess, @Nullable SalutCallback onFailure, boolean disableWiFi)
{
BackgroundClientRegistrationJob.onUnregisterSuccess = onSuccess;
BackgroundClientRegistrationJob.onUnregisterFailure = onFailure;
BackgroundClientRegistrationJob.disableWiFiOnUnregister = disableWiFi;
if(receiverRegistered)
{
dataReceiver.context.unregisterReceiver(receiver);
receiverRegistered = false;
}
if(!isConnectedToAnotherDevice)
{
Log.d(TAG, "Attempted to unregister, but not connected to group. The remote service may already have shutdown.");
thisDevice.isRegistered = false;
registeredHost = null;
closeDataSocket();
disconnectFromDevice();
if(onSuccess != null)
{
onSuccess.call();
}
}
else
{
startRegistrationForClient(new InetSocketAddress(registeredHost.serviceAddress, SALUT_SERVER_PORT));
}
}
示例3: setupDNSResponders
import com.peak.salut.Callbacks.SalutCallback; //导入方法依赖的package包/类
private void setupDNSResponders(final SalutCallback onDeviceFound, final boolean callContinously)
{
/*Here, we register a listener for when services are actually found. The WiFi P2P specification notes that we need two types of
*listeners, one for a DNS service and one for a TXT record. The DNS service listener is invoked whenever a service is found, regardless
*of whether or not it is yours. To that determine if it is, we must compare our service name with the service name. If it is our service,
* we simply log.*/
WifiP2pManager.DnsSdServiceResponseListener serviceListener = new WifiP2pManager.DnsSdServiceResponseListener() {
@Override
public void onDnsSdServiceAvailable(String instanceName, String serviceNameAndTP, WifiP2pDevice sourceDevice) {
Log.d(TAG, "Found " + instanceName + " " + serviceNameAndTP);
}
};
/*The TXT record contains specific information about a service and it's listener can also be invoked regardless of the device. Here, we
*double check if the device is ours, and then we go ahead and pull that specific information from it and put it into an Map. The function
*that was passed in early is also called.*/
WifiP2pManager.DnsSdTxtRecordListener txtRecordListener = new WifiP2pManager.DnsSdTxtRecordListener() {
@Override
public void onDnsSdTxtRecordAvailable(String serviceFullDomainName, Map<String, String> record, WifiP2pDevice device) {
if(!foundDevices.isEmpty())
{
for(SalutDevice found : foundDevices)
{
if(found.deviceName.equals(device.deviceName))
{
return;
}
}
}
if(record.containsValue(thisDevice.serviceName))
{
SalutDevice foundDevice = new SalutDevice(device, record);
foundDevices.add(foundDevice);
if(callContinously)
{
onDeviceFound.call();
}
else
{
if(!firstDeviceAlreadyFound)
{
onDeviceFound.call();
firstDeviceAlreadyFound = true;
}
}
}
}
};
manager.setDnsSdResponseListeners(channel, serviceListener, txtRecordListener);
respondersAlreadySet = true;
}
示例4: setupDNSResponders
import com.peak.salut.Callbacks.SalutCallback; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private void setupDNSResponders(final SalutCallback onDeviceFound, final boolean callContinously) {
/*Here, we register a listener for when services are actually found. The WiFi P2P specification notes that we need two types of
*listeners, one for a DNS service and one for a TXT record. The DNS service listener is invoked whenever a service is found, regardless
*of whether or not it is yours. To that determine if it is, we must compare our service name with the service name. If it is our service,
* we simply log.*/
WifiP2pManager.DnsSdServiceResponseListener serviceListener = new WifiP2pManager.DnsSdServiceResponseListener() {
@Override
public void onDnsSdServiceAvailable(String instanceName, String serviceNameAndTP, WifiP2pDevice sourceDevice) {
Log.d(TAG, "Found " + instanceName + " " + serviceNameAndTP);
}
};
/*The TXT record contains specific information about a service and it's listener can also be invoked regardless of the device. Here, we
*double check if the device is ours, and then we go ahead and pull that specific information from it and put it into an Map. The function
*that was passed in early is also called.*/
WifiP2pManager.DnsSdTxtRecordListener txtRecordListener = new WifiP2pManager.DnsSdTxtRecordListener() {
@Override
public void onDnsSdTxtRecordAvailable(String serviceFullDomainName, Map<String, String> record, WifiP2pDevice device) {
if (!foundDevices.isEmpty()) {
for (SalutDevice found : foundDevices) {
if (found.deviceName.equals(device.deviceName)) {
return;
}
}
}
if (record.containsValue(thisDevice.serviceName)) {
SalutDevice foundDevice = new SalutDevice(device, record);
foundDevices.add(foundDevice);
if (callContinously) {
onDeviceFound.call();
} else {
if (!firstDeviceAlreadyFound) {
onDeviceFound.call();
firstDeviceAlreadyFound = true;
}
}
}
}
};
manager.setDnsSdResponseListeners(channel, serviceListener, txtRecordListener);
respondersAlreadySet = true;
}