/*
     * Callback to receive connection notifications
     */
    private void ReceiveNotificationMessage(object sender, SpheroDeviceMessenger.MessengerEventArgs eventArgs)
    {
        SpheroDeviceNotification message = (SpheroDeviceNotification)eventArgs.Message;

        if (message.NotificationType == SpheroDeviceNotification.SpheroNotificationType.CONNECTED)
        {
            // Connect to the robot and move to the next scene designated by the developer
            if (!m_MultipleSpheros)
            {
                m_Title = "CONNECTION SUCCESS";
                SpheroDeviceMessenger.SharedInstance.NotificationReceived -= ReceiveNotificationMessage;
                {
                    if (m_threadSafeLoadLevel != null)
                    {
                        m_threadSafeLoadLevel.LoadLevel(m_NextLevel);
                    }
                }
            }
        }
        else if (message.NotificationType == SpheroDeviceNotification.SpheroNotificationType.CONNECTION_FAILED)
        {
            Sphero notifiedSphero = m_SpheroProvider.GetSphero(message.RobotID);
            // Connection only has failed if we are trying to connect to that robot the notification belongs to
            if (m_ConnectingRobotName.Equals(notifiedSphero.DeviceInfo.Name))
            {
                m_Title = "CONNECTION FAILED";
            }
        }
    }
Esempio n. 2
0
    /*
     * Callback to receive connection notifications
     */
    private void ReceiveNotificationMessage(object sender, SpheroDeviceMessenger.MessengerEventArgs eventArgs)
    {
        SpheroDeviceNotification message = (SpheroDeviceNotification)eventArgs.Message;

        if (message.NotificationType == SpheroDeviceNotification.SpheroNotificationType.CONNECTED)
        {
            // Go to the desired scene
            Application.LoadLevel(m_NextLevel);
        }
    }
Esempio n. 3
0
    /*
     * Callback to receive connection notifications
     */
    private void ReceiveNotificationMessage(object sender, SpheroDeviceMessenger.MessengerEventArgs eventArgs)
    {
        SpheroDeviceNotification message = (SpheroDeviceNotification)eventArgs.Message;
        Sphero notifiedSphero            = SpheroProvider.GetSharedProvider().GetSphero(message.RobotID);

        if (message.NotificationType == SpheroDeviceNotification.SpheroNotificationType.DISCONNECTED)
        {
            notifiedSphero.ConnectionState = Sphero.Connection_State.Disconnected;
            Application.LoadLevel("NoSpheroConnectedScene");
        }
    }
Esempio n. 4
0
    /*
     * Callback to receive connection notifications
     */
    private void ReceiveNotificationMessage(object sender, SpheroDeviceMessenger.MessengerEventArgs eventArgs)
    {
        SpheroDeviceNotification message = (SpheroDeviceNotification)eventArgs.Message;

        if (message.NotificationType == SpheroDeviceNotification.SpheroNotificationType.DISCONNECTED)
        {
            SpheroDeviceMessenger.SharedInstance.AsyncDataReceived    -= ReceiveAsyncMessage;
            SpheroDeviceMessenger.SharedInstance.NotificationReceived -=
                ReceiveNotificationMessage;
        }
    }
Esempio n. 5
0
    /*
     * Callback to receive connection notifications
     */
    private void ReceiveNotificationMessage(object sender, SpheroDeviceMessenger.MessengerEventArgs eventArgs)
    {
        // Event handler that listens for disconnects. An example of when one would be received is when Sphero
        // goes to sleep.
        SpheroDeviceNotification message = (SpheroDeviceNotification)eventArgs.Message;
        Sphero notifiedSphero            = SpheroProvider.GetSharedProvider().GetSphero(message.RobotID);

        if (message.NotificationType == SpheroDeviceNotification.SpheroNotificationType.DISCONNECTED)
        {
            notifiedSphero.ConnectionState = Sphero.Connection_State.Disconnected;
            streaming = false;
            Application.LoadLevel("NoSpheroConnectedScene");
        }
    }
Esempio n. 6
0
    /*
     * Callback to receive connection notifications
     */
    private void ReceiveNotificationMessage(object sender, SpheroDeviceMessenger.MessengerEventArgs eventArgs)
    {
        SpheroDeviceNotification message = (SpheroDeviceNotification)eventArgs.Message;

        if (message.NotificationType == SpheroDeviceNotification.SpheroNotificationType.CONNECTED)
        {
            // Go to the desired scene
            {
                if (m_threadSafeLoadLevel != null)
                {
                    m_threadSafeLoadLevel.LoadLevel("NoSpheroConnectedScene");
                }
            }
        }
    }
Esempio n. 7
0
    /*
     * Callback to receive connection notifications
     */
    private void ReceiveNotificationMessage(object sender, SpheroDeviceMessenger.MessengerEventArgs eventArgs)
    {
        SpheroDeviceNotification message = (SpheroDeviceNotification)eventArgs.Message;
        Sphero notifiedSphero            = GetSphero(message.RobotID);

        if (message.NotificationType == SpheroDeviceNotification.SpheroNotificationType.CONNECTED)
        {
            notifiedSphero.ConnectionState = Sphero.Connection_State.Connected;
        }
        else if (message.NotificationType == SpheroDeviceNotification.SpheroNotificationType.DISCONNECTED)
        {
            notifiedSphero.ConnectionState = Sphero.Connection_State.Disconnected;
        }
        else if (message.NotificationType == SpheroDeviceNotification.SpheroNotificationType.CONNECTION_FAILED)
        {
            notifiedSphero.ConnectionState = Sphero.Connection_State.Failed;
        }
    }
    /*
     * Callback to receive connection notifications
     */
    private void ReceiveNotificationMessage(object sender, SpheroDeviceMessenger.MessengerEventArgs eventArgs)
    {
        SpheroDeviceNotification message = (SpheroDeviceNotification)eventArgs.Message;
        Sphero notifiedSphero            = m_PairedSpheros[0];

        if (message.NotificationType == SpheroDeviceNotification.SpheroNotificationType.CONNECTED)
        {
            notifiedSphero.ConnectionState = Sphero.Connection_State.Connected;
            // Consider setting bluetooth device info here
        }
        else if (message.NotificationType == SpheroDeviceNotification.SpheroNotificationType.DISCONNECTED)
        {
            notifiedSphero.ConnectionState = Sphero.Connection_State.Disconnected;
        }
        else if (message.NotificationType == SpheroDeviceNotification.SpheroNotificationType.CONNECTION_FAILED)
        {
            notifiedSphero.ConnectionState = Sphero.Connection_State.Failed;
        }
    }