Exemplo n.º 1
0
    internal static void RemoteManagerStartRemoteDiscovery(Action <Remote> action)
    {
        if (Application.platform != RuntimePlatform.IPhonePlayer && Application.platform != RuntimePlatform.OSXPlayer)
        {
            return;
        }

        string identifier = "discovery-" + Guid.NewGuid().ToString();

        MiraRemoteException discoveryException = null;

        remoteActions[identifier] = (remote) => {
            action(remote);

            // Remove exception action, but this action is called once per discovered device, so can't remove this action yet.
            exceptionActions.Remove(identifier);
        };
        exceptionActions[identifier] = (exception) => {
            discoveryException = exception;
        };

        MRRemoteManagerStartRemoteDiscovery(identifier, DiscoveredRemoteCallback, ErrorCallback);

        if (discoveryException != null)
        {
            remoteActions.Remove(identifier);
            exceptionActions.Remove(identifier);

            throw discoveryException;
        }
    }
Exemplo n.º 2
0
    private static void ErrorCallback(string identifier, bool success, int errorCode, string message)
    {
        Action <MiraRemoteException> action = exceptionActions[identifier];

        MiraRemoteException exception = success ? new MiraRemoteException(message, (MiraRemoteErrorCode)errorCode) : null;

        action(exception);
    }