Bagikan melalui


MobileBroadbandDeviceServiceCommandSession.CommandReceived Kejadian

Definisi

Dimunculkan ketika peristiwa yang tidak diminta diterima dari perangkat broadband seluler pada objek MobileBroadbandDeviceServiceCommandSession setelah sesi dibuka.

Catatan

Fungsionalitas ini hanya tersedia untuk aplikasi operator seluler dan aplikasi UWP yang diberikan akses istimewa oleh operator jaringan seluler.

Jika Anda ingin menggunakan API ini dan menerbitkan aplikasi anda ke Microsoft Store, maka Anda akan memerlukan persetujuan khusus. Untuk informasi selengkapnya, lihat bagian Kemampuan terbatas dalam topik Deklarasi kemampuan aplikasi .

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

Jenis Acara

Persyaratan Windows

Rangkaian perangkat
Windows 11 Insider Preview (diperkenalkan dalam 10.0.26100.0)
API contract
Windows.Foundation.UniversalApiContract (diperkenalkan dalam v19.0)
Kemampuan aplikasi
cellularDeviceControl

Contoh

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

Keterangan

Jika Anda mengembangkan layanan NT atau driver mode pengguna yang mengontrol perangkat broadband seluler, maka kejadian ini memungkinkan Anda menerapkan penanganan aktivitas latar depan untuk menerima dan menangani pemberitahuan layanan perangkat.

Berlaku untuk