c-sharp icon indicating copy to clipboard operation
c-sharp copied to clipboard

Request response style api support

Open mohitpubnub opened this issue 4 months ago • 1 comments

Simple Usage (Builder Pattern)

var result = await pubnub.Publish()
    .Message("Hello World")
    .Channel("my-channel")
    .ExecuteAsync();

Advanced Usage (Request/Response Overload)

var response = await pubnub.Publish(new PublishRequest
{
    Message = new { text = "Hello", metadata = "value" },
    Channel = "my-channel",
    StoreInHistory = true,
    Ttl = 24,
    Metadata = new Dictionary<string, object> { { "type", "notification" } },
    UsePost = true
});

Error Handling

try
{
    var response = await pubnub.Publish(request);
    Console.WriteLine($"Published with timetoken: {response.Timetoken}");
}
catch (ArgumentException ex)
{
    Console.WriteLine($"Validation error: {ex.Message}");
}
catch (PNException ex)
{
    Console.WriteLine($"PubNub error: {ex.Message}");
}

mohitpubnub avatar Sep 25 '25 06:09 mohitpubnub

:tada: Snyk checks have passed. No issues have been found so far.

:white_check_mark: security/snyk check is complete. No issues have been found. (View Details)

:white_check_mark: license/snyk check is complete. No issues have been found. (View Details)

pubnub-ops-terraform avatar Sep 25 '25 06:09 pubnub-ops-terraform