Skip to content

Conversation

mohitpubnub
Copy link
Contributor

@mohitpubnub mohitpubnub commented Sep 25, 2025

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}");
}

@pubnub-ops-terraform
Copy link

pubnub-ops-terraform commented Sep 25, 2025

🎉 Snyk checks have passed. No issues have been found so far.

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants