Condividi tramite


MobileBroadbandDeviceServiceCommandSession.CommandReceived Evento

Definizione

Generato quando un evento non richiesto viene ricevuto da un dispositivo mobile broadband nell'oggetto MobileBroadbandDeviceServiceCommandSession dopo l'apertura della sessione.

Nota

Questa funzionalità è disponibile solo per le app dell'operatore di telefonia mobile e le app UWP con accesso con privilegi da parte degli operatori di rete mobile.

Se vuoi usare questa API e pubblicare la tua app in Microsoft Store, avrai bisogno di un'approvazione speciale. Per altre informazioni, vedere la sezione Funzionalità con restrizioni nell'argomento Dichiarazioni di funzionalità dell'app .

// 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 evento

Requisiti Windows

Famiglia di dispositivi
Windows 11 Insider Preview (è stato introdotto in 10.0.26100.0)
API contract
Windows.Foundation.UniversalApiContract (è stato introdotto in v19.0)
Funzionalità dell'app
cellularDeviceControl

Esempio

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();
        }
    }
}

Commenti

Se si sviluppa un servizio NT o un driver in modalità utente che controlla i dispositivi mobili a banda larga, questo evento consente di implementare un gestore eventi in primo piano per ricevere e gestire le notifiche del servizio dispositivo.

Si applica a