Official C# SDK for the Fluxum API service
Get up and running with the Fluxum C# SDK in minutes
dotnet add package FluxumSDKConnect to Fluxum's WebSocket gateway for instant job updates and real-time communication.
Optional RSA key management for end-to-end encryption and maximum security.
Track performance metrics, connection status, and job statistics with built-in analytics.
Handle real-time events with the SDK
// Connection events
sdk.Connected += (sender, e) => Console.WriteLine("Connected to Fluxum server");
sdk.Authenticated += (sender, e) => Console.WriteLine("Authentication successful");
sdk.Disconnected += (sender, e) => Console.WriteLine($"Disconnected: {e.Reason}");
// Job events
sdk.JobSubmitted += (sender, e) => Console.WriteLine($"Job submitted: {e.JobId}");
sdk.JobAccepted += (sender, e) => Console.WriteLine($"Job accepted: {e.JobId}");
sdk.JobUpdate += (sender, e) => Console.WriteLine($"Job update: {e.JobId}, {e.Status}");
// Error handling
sdk.Error += (sender, e) => Console.WriteLine($"Error: {e.Type}, {e.Message}");
// Rate limiting
sdk.RateLimitStatus += (sender, e) => Console.WriteLine($"Rate limit: {e.IsRateLimited}");Examples of different job types and configurations
var job = new JobPayload
{
TargetUrl = "https://api.example.com/data",
Method = "GET",
Headers = new Dictionary<string, string>
{
{ "Authorization", "Bearer your-token" }
}
};
var jobId = await sdk.SubmitJob(job);var job = new JobPayload
{
TargetUrl = "https://api.example.com/users",
Method = "POST",
Headers = new Dictionary<string, string>
{
{ "Content-Type", "application/json" },
{ "Authorization", "Bearer your-token" }
},
Body = JsonSerializer.Serialize(new
{
name = "John Doe",
email = "[email protected]"
})
};
var jobId = await sdk.SubmitJob(job);var job = new JobPayload
{
TargetUrl = "https://api.example.com/upload",
Method = "POST",
Headers = new Dictionary<string, string>
{
{ "Content-Type", "multipart/form-data" }
},
Body = formData // FormData object
};
var jobId = await sdk.SubmitJob(job);Advanced configuration and features
var sdk = new FluxumSDK(new FluxumSDKOptions
{
ApiKey = "your-api-key",
EnableClientSideEncryption = true,
EncryptionKey = "your-custom-encryption-key"
});// Manual connection
await sdk.ConnectAsync();
// Disconnect
await sdk.DisconnectAsync();
// Check connection status
if (sdk.IsConnected)
{
Console.WriteLine("Connected");
}
// Reconnect
await sdk.ReconnectAsync();// Get analytics data
var analytics = sdk.GetAnalytics();
Console.WriteLine($"Total jobs: {analytics.TotalJobs}");
Console.WriteLine($"Successful jobs: {analytics.SuccessfulJobs}");
Console.WriteLine($"Failed jobs: {analytics.FailedJobs}");
Console.WriteLine($"Average response time: {analytics.AverageResponseTime}");
// Reset analytics
sdk.ResetAnalytics();Comprehensive error handling and recovery
// Global error handler
sdk.Error += (sender, e) =>
{
switch (e.Type)
{
case ErrorType.Connection:
Console.WriteLine($"Connection error: {e.Message}");
break;
case ErrorType.Authentication:
Console.WriteLine($"Authentication error: {e.Message}");
break;
case ErrorType.Job:
Console.WriteLine($"Job error: {e.Message}");
break;
case ErrorType.RateLimit:
Console.WriteLine($"Rate limit exceeded: {e.Message}");
break;
default:
Console.WriteLine($"Unknown error: {e.Message}");
break;
}
};
// Handle specific errors
sdk.ConnectionFailed += (sender, e) =>
{
Console.WriteLine($"Failed to connect: {e.Message}");
// Implement retry logic
};
sdk.AuthenticationFailed += (sender, e) =>
{
Console.WriteLine($"Authentication failed: {e.Message}");
// Handle invalid API key
};System requirements and dependencies
.NET 6.0 or higher
Complete API documentation
new FluxumSDK(FluxumSDKOptions options)
public class FluxumSDKOptions
{
public string ApiKey { get; set; }
public bool AutoConnect { get; set; } = true;
public bool EnableClientSideEncryption { get; set; } = true;
public bool EnableAnalytics { get; set; } = true;
public int MaxReconnectAttempts { get; set; } = 5;
public int ReconnectDelay { get; set; } = 1000;
public int ConnectionTimeout { get; set; } = 30000;
public LogLevel LogLevel { get; set; } = LogLevel.Info;
}// Connection
await sdk.ConnectAsync();
await sdk.DisconnectAsync();
await sdk.ReconnectAsync();
// Status
sdk.isConnected() -> bool
sdk.isauthenticated() -> bool
// Jobs
fun submitJob(payload: JobPayload) -> str
fun cancelJob(jobId: str) -> None
// Analytics
fun get_analytics() -> AnalyticsData
fun reset_analytics() -> None
// Events
fun addEventListener(listener: SDKEventListener)
fun removeEventListener(listener: SDKEventListener)