Freigeben über


WebPubSubServiceClient.SendToConnectionAsync Methode

Definition

Überlädt

SendToConnectionAsync(String, String, ContentType)

Senden einer Nachricht an die spezifische Verbindung

SendToConnectionAsync(String, RequestContent, ContentType, RequestContext)

Inhalt im Anforderungstext an die spezifische Verbindung senden.

SendToConnectionAsync(String, String, ContentType)

Source:
WebPubSubServiceClient.cs

Senden einer Nachricht an die spezifische Verbindung

public virtual System.Threading.Tasks.Task<Azure.Response> SendToConnectionAsync (string connectionId, string content, Azure.Core.ContentType contentType = default);
abstract member SendToConnectionAsync : string * string * Azure.Core.ContentType -> System.Threading.Tasks.Task<Azure.Response>
override this.SendToConnectionAsync : string * string * Azure.Core.ContentType -> System.Threading.Tasks.Task<Azure.Response>
Public Overridable Function SendToConnectionAsync (connectionId As String, content As String, Optional contentType As ContentType = Nothing) As Task(Of Response)

Parameter

connectionId
String

Die Verbindungs-ID.

content
String
contentType
ContentType

Der Standardwert ist ContentType.PlainText.

Gibt zurück

Ein Response , wenn erfolgreich.

Gilt für:

SendToConnectionAsync(String, RequestContent, ContentType, RequestContext)

Source:
WebPubSubServiceClient.cs

Inhalt im Anforderungstext an die spezifische Verbindung senden.

public virtual System.Threading.Tasks.Task<Azure.Response> SendToConnectionAsync (string connectionId, Azure.Core.RequestContent content, Azure.Core.ContentType contentType, Azure.RequestContext context = default);
abstract member SendToConnectionAsync : string * Azure.Core.RequestContent * Azure.Core.ContentType * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
override this.SendToConnectionAsync : string * Azure.Core.RequestContent * Azure.Core.ContentType * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
Public Overridable Function SendToConnectionAsync (connectionId As String, content As RequestContent, contentType As ContentType, Optional context As RequestContext = Nothing) As Task(Of Response)

Parameter

connectionId
String

Die Verbindungs-ID.

content
RequestContent

Der Inhalt, der als Text der Anforderung gesendet werden soll. Details zum Anforderungstextschema finden Sie unten im Abschnitt Hinweise.

contentType
ContentType

Dateityp hochladen. Zulässige Werte: "application/json" | "application/octet-stream" | "text/plain".

context
RequestContext

Der Anforderungskontext, der das Standardverhalten der Clientpipeline pro Aufruf außer Kraft setzen kann.

Gibt zurück

Die vom Dienst zurückgegebene Antwort.

Ausnahmen

connectionId oder content ist NULL.

connectionId ist eine leere Zeichenfolge und wurde erwartet, dass sie nicht leer ist.

Der Dienst hat einen nicht erfolgreichen status Code zurückgegeben.

Beispiele

In diesem Beispiel wird gezeigt, wie SendToConnectionAsync mit erforderlichen Parametern und Anforderungsinhalten aufgerufen wird.

var client = new WebPubSubServiceClient("<https://my-service.azure.com>", "<hub>");

var data = File.OpenRead("<filePath>");

Response response = await client.SendToConnectionAsync("<connectionId>", RequestContent.Create(data), ContentType.ApplicationOctetStream);
Console.WriteLine(response.Status);

Hinweise

Schema für Response Error:

{
              code: string,
              message: string,
              target: string,
              details: [ErrorDetail],
              inner: {
                code: string,
                inner: InnerError
              }
            }

Gilt für: