Condividi tramite


DatagramSocket.MessageReceived Evento

Definizione

Evento che indica che è stato ricevuto un messaggio nell'oggetto DatagramSocket .

// Register
event_token MessageReceived(TypedEventHandler<DatagramSocket, DatagramSocketMessageReceivedEventArgs const&> const& handler) const;

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

// Revoke with event_revoker
DatagramSocket::MessageReceived_revoker MessageReceived(auto_revoke_t, TypedEventHandler<DatagramSocket, DatagramSocketMessageReceivedEventArgs const&> const& handler) const;
public event TypedEventHandler<DatagramSocket,DatagramSocketMessageReceivedEventArgs> MessageReceived;
function onMessageReceived(eventArgs) { /* Your code */ }
datagramSocket.addEventListener("messagereceived", onMessageReceived);
datagramSocket.removeEventListener("messagereceived", onMessageReceived);
- or -
datagramSocket.onmessagereceived = onMessageReceived;
Public Custom Event MessageReceived As TypedEventHandler(Of DatagramSocket, DatagramSocketMessageReceivedEventArgs) 

Tipo evento

Requisiti Windows

Funzionalità dell'app
ID_CAP_NETWORKING [Windows Phone]

Commenti

Per ricevere dati sull'oggetto DatagramSocket , un'app deve assegnare l'evento [MessageReceived a un gestore eventi e quindi chiamare il metodo BindEndpointAsync o BindServiceNameAsync per associare DatagramSocket a un nome di servizio locale o a una porta UDP. I metodi ConnectAsync genereranno anche un'operazione di associazione. La scrittura in un flusso restituito da uno dei metodi GetOutputStreamAsync comporterà anche un'operazione di associazione. Il gestore eventi MessageReceived verrà richiamato ogni volta che arriva un messaggio da un endpoint remoto.

Per ricevere pacchetti multicast nell'oggetto DatagramSocket , un'app deve assegnare l'evento [MessageReceived a un gestore eventi e quindi chiamare il metodo JoinMulticastGroup per partecipare al gruppo multicast.

Per annullare la registrazione dell'evento [MessageReceived, è necessario chiudere l'oggetto DatagramSocket . Il metodo Close viene usato dall'app di Windows con JavaScript. Per le app scritte con .NET Framework 4.5 in C# e VB.NET, il metodo Close viene esposto come metodo in DatagramSocket. Per le app scritte in C++, il metodo Close verrà chiamato quando si usa la parola chiave delete nell'oggetto .

Si applica a

Vedi anche