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


Java SalutCallback类代码示例

本文整理汇总了Java中com.peak.salut.Callbacks.SalutCallback的典型用法代码示例。如果您正苦于以下问题:Java SalutCallback类的具体用法?Java SalutCallback怎么用?Java SalutCallback使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: startRegistration

import com.peak.salut.Callbacks.SalutCallback; //导入依赖的package包/类
public void startRegistration() {
    try {
        FullscreenActivity.dataReceiver = new SalutDataReceiver(StageMode.this, StageMode.this);
        FullscreenActivity.serviceData = new SalutServiceData("OpenSongApp", 60606,
                FullscreenActivity.mBluetoothName);

        FullscreenActivity.network = new Salut(FullscreenActivity.dataReceiver, FullscreenActivity.serviceData, new SalutCallback() {
            @Override
            public void call() {
                FullscreenActivity.salutLog += "\n" + getResources().getString(R.string.nowifidirect);
            }
        });

    } catch (Exception e) {
        FullscreenActivity.salutLog += "\n" + getResources().getString(R.string.nowifidirect);
        e.printStackTrace();
    }
}
 
开发者ID:thebigg73,项目名称:OpenSongTablet,代码行数:19,代码来源:StageMode.java

示例2: startRegistration

import com.peak.salut.Callbacks.SalutCallback; //导入依赖的package包/类
public void startRegistration() {
    try {
        FullscreenActivity.dataReceiver = new SalutDataReceiver(PresenterMode.this, PresenterMode.this);
        FullscreenActivity.serviceData = new SalutServiceData("OpenSongApp", 60606,
                FullscreenActivity.mBluetoothName);

        FullscreenActivity.network = new Salut(FullscreenActivity.dataReceiver, FullscreenActivity.serviceData, new SalutCallback() {
            @Override
            public void call() {
                FullscreenActivity.salutLog += "\n" + getResources().getString(R.string.nowifidirect);
            }
        });

    } catch (Exception e) {
        FullscreenActivity.salutLog += "\n" + getResources().getString(R.string.nowifidirect);
        e.printStackTrace();
    }
}
 
开发者ID:thebigg73,项目名称:OpenSongTablet,代码行数:19,代码来源:PresenterMode.java

示例3: connectToDevice

import com.peak.salut.Callbacks.SalutCallback; //导入依赖的package包/类
private void connectToDevice(final SalutDevice device, final SalutCallback onFailure)
{

    WifiP2pConfig config = new WifiP2pConfig();
    config.deviceAddress = device.macAddress;
    manager.connect(channel, config, new WifiP2pManager.ActionListener() {

        @Override
        public void onSuccess() {
            Log.d(TAG, "Attempting to connect to another device.");
            lastConnectedDevice = device;
        }

        @Override
        public void onFailure(int reason) {
            onFailure.call();
            Log.e(TAG, "Failed to connect to device. ");
        }
    });
}
 
开发者ID:uin3566,项目名称:GoBang,代码行数:21,代码来源:Salut.java

示例4: startNetworkService

import com.peak.salut.Callbacks.SalutCallback; //导入依赖的package包/类
public void startNetworkService(@Nullable SalutDeviceCallback onDeviceRegisteredWithHost, @Nullable SalutCallback onSuccess,  @Nullable SalutCallback onFailure)
{
    //In order to have a service that you create be seen, you must also actively look for other services. This is an Android bug.
    //For more information, read here. https://code.google.com/p/android/issues/detail?id=37425
    //We do not need to setup DNS responders.
    registeredClients = new ArrayList<>();

    this.onDeviceRegisteredWithHost = onDeviceRegisteredWithHost;

    if(!receiverRegistered)
    {
        dataReceiver.context.registerReceiver(receiver, intentFilter);
        receiverRegistered = true;
    }

    createService(onSuccess, onFailure);
    discoverNetworkServices(deviceNotSupported);
}
 
开发者ID:uin3566,项目名称:GoBang,代码行数:19,代码来源:Salut.java

示例5: devicesNotFoundInTime

import com.peak.salut.Callbacks.SalutCallback; //导入依赖的package包/类
private void devicesNotFoundInTime(final SalutCallback cleanUpFunction, final SalutCallback devicesFound, int timeout) {
    new Handler().postDelayed(new Runnable() {
        @Override
        public void run() {
            if(connectingIsCanceled)
            {
                connectingIsCanceled = false;
                cleanUpFunction.call();
            }
            else {
                if (foundDevices.isEmpty()) {
                    cleanUpFunction.call();
                } else {
                    devicesFound.call();
                }
                stopServiceDiscovery(false);
            }
        }
    }, timeout);
}
 
开发者ID:uin3566,项目名称:GoBang,代码行数:21,代码来源:Salut.java

示例6: startNetService

import com.peak.salut.Callbacks.SalutCallback; //导入依赖的package包/类
public void startNetService() {
    mSalut.startNetworkService(new SalutDeviceCallback() {
        @Override
        public void call(SalutDevice salutDevice) {
            Log.i(TAG, "startNetworkService, onWifiDeviceConnected, device:" + salutDevice.deviceName);
            mSendToDevice = salutDevice;
            mCallback.onWifiDeviceConnected(salutDevice);
        }
    }, new SalutCallback() {
        @Override
        public void call() {
            Log.i(TAG, "startNetworkService, init success");
        }
    }, new SalutCallback() {
        @Override
        public void call() {
            Log.i(TAG, "startNetworkService, init failed");
            mCallback.onStartWifiServiceFailed();
        }
    });
}
 
开发者ID:uin3566,项目名称:GoBang,代码行数:22,代码来源:WifiInteractor.java

示例7: sendToDevice

import com.peak.salut.Callbacks.SalutCallback; //导入依赖的package包/类
public void sendToDevice(Message message, boolean isHost) {
    if (isHost) {
        if (mSendToDevice != null) {
            mSalut.sendToDevice(mSendToDevice, message, new SalutCallback() {
                @Override
                public void call() {
                    Log.i(TAG, "sendToDevice, send data failed");
                    mCallback.onSendMessageFailed();
                }
            });
        }
    } else {
        mSalut.sendToHost(message, new SalutCallback() {
            @Override
            public void call() {
                Log.i(TAG, "sendToHost, send data failed");
            }
        });
    }
}
 
开发者ID:uin3566,项目名称:GoBang,代码行数:21,代码来源:WifiInteractor.java

示例8: connectToDevice

import com.peak.salut.Callbacks.SalutCallback; //导入依赖的package包/类
private void connectToDevice(final SalutDevice device, final SalutCallback onFailure) {

        WifiP2pConfig config = new WifiP2pConfig();
        config.deviceAddress = device.macAddress;
        manager.connect(channel, config, new WifiP2pManager.ActionListener() {

            @Override
            public void onSuccess() {
                Log.d(TAG, "Attempting to connect to another device.");
                lastConnectedDevice = device;
            }

            @Override
            public void onFailure(int reason) {
                onFailure.call();
                Log.e(TAG, "Failed to connect to device. ");
            }
        });
    }
 
开发者ID:markrjr,项目名称:Salut,代码行数:20,代码来源:Salut.java

示例9: createGroup

import com.peak.salut.Callbacks.SalutCallback; //导入依赖的package包/类
public void createGroup(final SalutCallback onSuccess, final SalutCallback onFailure) {
    manager.createGroup(channel, new WifiP2pManager.ActionListener() {
        @Override
        public void onSuccess() {
            Log.v(TAG, "Successfully created group.");
            Log.d(TAG, "Successfully created " + thisDevice.serviceName + " service running on port " + thisDevice.servicePort);
            isRunningAsHost = true;
            if (onSuccess != null) {
                onSuccess.call();
            }
        }

        @Override
        public void onFailure(int reason) {
            Log.e(TAG, "Failed to create group. Reason :" + reason);
            if (onFailure != null)
                onFailure.call();
        }
    });

}
 
开发者ID:markrjr,项目名称:Salut,代码行数:22,代码来源:Salut.java

示例10: 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

示例11: startNetworkService

import com.peak.salut.Callbacks.SalutCallback; //导入依赖的package包/类
public void startNetworkService(@Nullable SalutDeviceCallback onDeviceRegisteredWithHost, @Nullable SalutCallback onSuccess, @Nullable SalutCallback onFailure) {
    //In order to have a service that you create be seen, you must also actively look for other services. This is an Android bug.
    //For more information, read here. https://code.google.com/p/android/issues/detail?id=37425
    //We do not need to setup DNS responders.
    registeredClients = new ArrayList<>();

    this.onDeviceRegisteredWithHost = onDeviceRegisteredWithHost;

    if (!receiverRegistered) {
        dataReceiver.context.registerReceiver(receiver, intentFilter);
        receiverRegistered = true;
    }

    createService(onSuccess, onFailure);
    discoverNetworkServices(deviceNotSupported);
}
 
开发者ID:markrjr,项目名称:Salut,代码行数:17,代码来源:Salut.java

示例12: devicesNotFoundInTime

import com.peak.salut.Callbacks.SalutCallback; //导入依赖的package包/类
private void devicesNotFoundInTime(final SalutCallback cleanUpFunction, final SalutCallback devicesFound, int timeout) {
    new Handler().postDelayed(new Runnable() {
        @Override
        public void run() {
            if (connectingIsCanceled) {
                connectingIsCanceled = false;
                cleanUpFunction.call();
            } else {
                if (foundDevices.isEmpty()) {
                    cleanUpFunction.call();
                } else {
                    devicesFound.call();
                }
                stopServiceDiscovery(false);
            }
        }
    }, timeout);
}
 
开发者ID:markrjr,项目名称:Salut,代码行数:19,代码来源:Salut.java

示例13: Salut

import com.peak.salut.Callbacks.SalutCallback; //导入依赖的package包/类
public Salut(SalutDataReceiver dataReceiver, SalutServiceData salutServiceData, SalutCallback deviceNotSupported)
{
    WifiManager wifiMan = (WifiManager) dataReceiver.context.getSystemService(Context.WIFI_SERVICE);
    WifiInfo wifiInfo = wifiMan.getConnectionInfo();

    this.dataReceiver = dataReceiver;
    this.deviceNotSupported = deviceNotSupported;
    this.TTP = salutServiceData.serviceData.get("SERVICE_NAME") + TTP;

    thisDevice = new SalutDevice();
    thisDevice.serviceName = salutServiceData.serviceData.get("SERVICE_NAME");
    thisDevice.readableName = salutServiceData.serviceData.get("INSTANCE_NAME");
    thisDevice.instanceName = "" + wifiInfo.getMacAddress().hashCode();
    thisDevice.macAddress = wifiInfo.getMacAddress();
    thisDevice.TTP = thisDevice.serviceName + TTP;
    thisDevice.servicePort = Integer.valueOf(salutServiceData.serviceData.get("SERVICE_PORT"));
    thisDevice.txtRecord = salutServiceData.serviceData;

    foundDevices = new ArrayList<>();

    intentFilter.addAction(WifiP2pManager.WIFI_P2P_STATE_CHANGED_ACTION);
    intentFilter.addAction(WifiP2pManager.WIFI_P2P_PEERS_CHANGED_ACTION);
    intentFilter.addAction(WifiP2pManager.WIFI_P2P_CONNECTION_CHANGED_ACTION);
    intentFilter.addAction(WifiP2pManager.WIFI_P2P_THIS_DEVICE_CHANGED_ACTION);

    manager = (WifiP2pManager) dataReceiver.context.getSystemService(Context.WIFI_P2P_SERVICE);
    channel = manager.initialize(dataReceiver.context, dataReceiver.context.getMainLooper(), new WifiP2pManager.ChannelListener() {
        @Override
        public void onChannelDisconnected() {
            Log.d(TAG, "Attempting to reinitialize channel.");
            channel = manager.initialize(Salut.this.dataReceiver.context,Salut.this.dataReceiver.context.getMainLooper(), this);
        }
    });

    receiver = new SalutBroadcastReciever(this, manager, channel);
}
 
开发者ID:uin3566,项目名称:GoBang,代码行数:37,代码来源:Salut.java

示例14: registerWithHost

import com.peak.salut.Callbacks.SalutCallback; //导入依赖的package包/类
public void registerWithHost(final SalutDevice device, @Nullable SalutCallback onRegistered, @Nullable final SalutCallback onRegistrationFail)
{
    BackgroundClientRegistrationJob.onRegistered = onRegistered;
    BackgroundClientRegistrationJob.onRegistrationFail = onRegistrationFail;
    this.unexpectedDisconnect = onRegistrationFail;
    connectToDevice(device, onRegistrationFail);
}
 
开发者ID:uin3566,项目名称:GoBang,代码行数:8,代码来源:Salut.java

示例15: sendToAllDevices

import com.peak.salut.Callbacks.SalutCallback; //导入依赖的package包/类
public void sendToAllDevices(final Object data, @Nullable final SalutCallback onFailure)
{
    if(isRunningAsHost)
    {
        for(SalutDevice registered : registeredClients) {
            sendData(registered, data, onFailure);
        }
    }
    else
    {
        Log.e(TAG, "You must be running as the host to invoke this method.");
    }
}
 
开发者ID:uin3566,项目名称:GoBang,代码行数:14,代码来源:Salut.java


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