共用方式為


StreamSocketListener.ConnectionReceived 事件

定義

事件,指出 已在 StreamSocketListener 物件上收到連接。

// Register
event_token ConnectionReceived(TypedEventHandler<StreamSocketListener, StreamSocketListenerConnectionReceivedEventArgs const&> const& handler) const;

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

// Revoke with event_revoker
StreamSocketListener::ConnectionReceived_revoker ConnectionReceived(auto_revoke_t, TypedEventHandler<StreamSocketListener, StreamSocketListenerConnectionReceivedEventArgs const&> const& handler) const;
public event TypedEventHandler<StreamSocketListener,StreamSocketListenerConnectionReceivedEventArgs> ConnectionReceived;
function onConnectionReceived(eventArgs) { /* Your code */ }
streamSocketListener.addEventListener("connectionreceived", onConnectionReceived);
streamSocketListener.removeEventListener("connectionreceived", onConnectionReceived);
- or -
streamSocketListener.onconnectionreceived = onConnectionReceived;
Public Custom Event ConnectionReceived As TypedEventHandler(Of StreamSocketListener, StreamSocketListenerConnectionReceivedEventArgs) 

事件類型

Windows 需求

應用程式功能
ID_CAP_NETWORKING [Windows Phone]

備註

若要接聽 StreamSocketListener 物件的連線,應用程式必須將 ConnectionReceived 事件指派給事件處理常式,然後呼叫 BindEndpointAsyncBindServiceNameAsync 方法,將 StreamSocketListener 系結至要接聽的本機服務名稱或 TCP 埠。 若要接聽藍牙 RFCOMM,系結會是藍牙服務識別碼。

注意StreamSocket的觀點來看,平行模式程式庫 (PPL) 完成處理常式會執行 (,而且通訊端在接續本文執行之前符合處置) 資格。 因此,如果您想要在接續內使用它,若要讓您的通訊端不受處置,您必須使用 C++ PPL 接續中 StreamSocket 參考中所述的其中一種技術。

適用於

另請參閱