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


Java SalutCallback.call方法代码示例

本文整理汇总了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));
        }
    }
 
开发者ID:markrjr,项目名称:Salut,代码行数:25,代码来源:Salut.java

示例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));
    }
}
 
开发者ID:uin3566,项目名称:GoBang,代码行数:31,代码来源:Salut.java

示例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;
}
 
开发者ID:uin3566,项目名称:GoBang,代码行数:59,代码来源:Salut.java

示例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;
}
 
开发者ID:markrjr,项目名称:Salut,代码行数:51,代码来源:Salut.java


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