Compartir a través de


MobileBroadbandDeviceServiceCommandSession.CommandReceived Evento

Definición

Se genera cuando se recibe un evento no solicitado de un dispositivo de banda ancha móvil en el objeto MobileBroadbandDeviceServiceCommandSession después de abrir la sesión.

Nota

Esta funcionalidad solo está disponible para las aplicaciones de operador de telefonía móvil y las aplicaciones para UWP con acceso con privilegios por parte de los operadores de red móvil.

Si quieres usar esta API y publicar tu aplicación en Microsoft Store, necesitarás aprobación especial. Para obtener más información, consulte la sección Funcionalidades restringidas del tema Declaraciones de funcionalidad de la aplicación.

// Register
event_token CommandReceived(TypedEventHandler<MobileBroadbandDeviceServiceCommandSession, MobileBroadbandDeviceServiceCommandEventArgs const&> const& handler) const;

// Revoke with event_token
void CommandReceived(event_token const* cookie) const;

// Revoke with event_revoker
MobileBroadbandDeviceServiceCommandSession::CommandReceived_revoker CommandReceived(auto_revoke_t, TypedEventHandler<MobileBroadbandDeviceServiceCommandSession, MobileBroadbandDeviceServiceCommandEventArgs const&> const& handler) const;
public event TypedEventHandler<MobileBroadbandDeviceServiceCommandSession,MobileBroadbandDeviceServiceCommandEventArgs> CommandReceived;
function onCommandReceived(eventArgs) { /* Your code */ }
mobileBroadbandDeviceServiceCommandSession.addEventListener("commandreceived", onCommandReceived);
mobileBroadbandDeviceServiceCommandSession.removeEventListener("commandreceived", onCommandReceived);
- or -
mobileBroadbandDeviceServiceCommandSession.oncommandreceived = onCommandReceived;
Public Custom Event CommandReceived As TypedEventHandler(Of MobileBroadbandDeviceServiceCommandSession, MobileBroadbandDeviceServiceCommandEventArgs) 

Tipo de evento

Requisitos de Windows

Familia de dispositivos
Windows 11, version 24H2 (se introdujo en la versión 10.0.26100.0)
API contract
Windows.Foundation.UniversalApiContract (se introdujo en la versión v19.0)
Características de aplicaciones
cellularDeviceControl

Ejemplos

using System;
using System.Threading;
using Windows.Foundation;
using Windows.Networking.NetworkOperators;

public class MobileBroadbandDeviceServiceCommandEventSample
{
    private const string sampleServiceId = "abcdefg-1234-abcd-1234-abcd1234abcd";
    private AutoResetEvent dsCommandReceivedEvent = new AutoResetEvent(false);

    public void DeviceServiceCommandSessionCommandReceived()
    {
        var modem = MobileBroadbandModem.GetDefault();
        if (modem == null)
        {
            // Handle the error.
            return;
        }

        MobileBroadbandDeviceService sampleService = modem.GetDeviceService(new Guid(sampleServiceId));
        if (sampleService == null)
        {
            // Handle the error.
            return;
        }

        var commandSession = sampleService.OpenCommandSession();
        commandSession.CommandReceived +=
                    new TypedEventHandler<MobileBroadbandDeviceServiceCommandSession,
                        MobileBroadbandDeviceServiceCommandEventArgs>(this.CommandReceivedHandler);

        bool CommandReceived = dsCommandReceivedEvent.WaitOne(10000);
        if (!CommandReceived)
        {
            // Handle the error.
        }

        commandSession.CommandReceived -= this.CommandReceivedHandler;
    }

    private void CommandReceivedHandler(MobileBroadbandDeviceServiceCommandSession sender,
        MobileBroadbandDeviceServiceCommandEventArgs e)
    {
        if (e != null)
        {
            Console.WriteLine("Received device service event");
            Console.WriteLine("  DeviceId: " + e.DeviceId);
            Console.WriteLine("  DeviceServiceId: " + e.DeviceServiceId);
            Console.WriteLine("  EventId: " + e.EventId);
            Console.WriteLine("  Received data: " + e.ReceivedData);
            dsCommandReceivedEvent.Set();
        }
    }
}

Comentarios

Si está desarrollando un servicio NT o un controlador en modo de usuario que controla los dispositivos móviles de banda ancha, este evento le permite implementar un controlador de eventos en primer plano para recibir y controlar las notificaciones del servicio de dispositivos.

Se aplica a