Megosztás a következőn keresztül:


WebPubSubServiceClient.SendToUser Method

Definition

Overloads

SendToUser(String, String, ContentType)

Send message to the specific user.

SendToUser(String, RequestContent, ContentType, RequestContext)

Send content inside request body to the specific user.

SendToUser(String, RequestContent, ContentType, String, RequestContext)

[Protocol Method] Send content inside request body to the specific user.

  • This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.

SendToUser(String, String, ContentType)

Source:
WebPubSubServiceClient_extensions.cs

Send message to the specific user.

public virtual Azure.Response SendToUser (string userId, string content, Azure.Core.ContentType contentType = default);
abstract member SendToUser : string * string * Azure.Core.ContentType -> Azure.Response
override this.SendToUser : string * string * Azure.Core.ContentType -> Azure.Response
Public Overridable Function SendToUser (userId As String, content As String, Optional contentType As ContentType = Nothing) As Response

Parameters

userId
String

The user Id.

content
String
contentType
ContentType

Defaults to ContentType.PlainText.

Returns

A Response if successful.

Applies to

SendToUser(String, RequestContent, ContentType, RequestContext)

Source:
WebPubSubServiceClient.cs

Send content inside request body to the specific user.

public virtual Azure.Response SendToUser (string userId, Azure.Core.RequestContent content, Azure.Core.ContentType contentType, Azure.RequestContext context);
abstract member SendToUser : string * Azure.Core.RequestContent * Azure.Core.ContentType * Azure.RequestContext -> Azure.Response
override this.SendToUser : string * Azure.Core.RequestContent * Azure.Core.ContentType * Azure.RequestContext -> Azure.Response
Public Overridable Function SendToUser (userId As String, content As RequestContent, contentType As ContentType, context As RequestContext) As Response

Parameters

userId
String

The user Id.

content
RequestContent

The content to send as the body of the request. Details of the request body schema are in the Remarks section below.

contentType
ContentType

Upload file type. Allowed values: "application/json" | "application/octet-stream" | "text/plain".

context
RequestContext

The request context, which can override default behaviors of the client pipeline on a per-call basis.

Returns

The response returned from the service.

Exceptions

userId or content is null.

userId is an empty string, and was expected to be non-empty.

Service returned a non-success status code.

Examples

This sample shows how to call SendToUser with required parameters and request content.

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

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

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

Remarks

Schema for Response Error:

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

Applies to

SendToUser(String, RequestContent, ContentType, String, RequestContext)

Source:
WebPubSubServiceClient.cs

[Protocol Method] Send content inside request body to the specific user.

  • This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
public virtual Azure.Response SendToUser (string userId, Azure.Core.RequestContent content, Azure.Core.ContentType contentType, string filter = default, Azure.RequestContext context = default);
abstract member SendToUser : string * Azure.Core.RequestContent * Azure.Core.ContentType * string * Azure.RequestContext -> Azure.Response
override this.SendToUser : string * Azure.Core.RequestContent * Azure.Core.ContentType * string * Azure.RequestContext -> Azure.Response
Public Overridable Function SendToUser (userId As String, content As RequestContent, contentType As ContentType, Optional filter As String = Nothing, Optional context As RequestContext = Nothing) As Response

Parameters

userId
String

The user Id.

content
RequestContent

The content to send as the body of the request.

contentType
ContentType

Upload file type. Allowed values: "application/json" | "application/octet-stream" | "text/plain".

filter
String

Following OData filter syntax to filter out the subscribers receiving the messages.

context
RequestContext

The request context, which can override default behaviors of the client pipeline on a per-call basis.

Returns

The response returned from the service.

Exceptions

userId or content is null.

userId is an empty string, and was expected to be non-empty.

Service returned a non-success status code.

Examples

This sample shows how to call SendToUser.

WebPubSubServiceClient client = new WebPubSubServiceClient("<Endpoint>", "<Hub>");

using RequestContent content = RequestContent.Create(File.OpenRead("<filePath>"));
Response response = client.SendToUser("<userId>", content, new ContentType("application/json"));

Console.WriteLine(response.Status);

This sample shows how to call SendToUser with all parameters and request content.

WebPubSubServiceClient client = new WebPubSubServiceClient("<Endpoint>", "<Hub>");

using RequestContent content = RequestContent.Create(File.OpenRead("<filePath>"));
Response response = client.SendToUser("<userId>", content, new ContentType("application/json"), filter: "<filter>");

Console.WriteLine(response.Status);

Applies to