A Blazor WebRTC component library for Telnyx, enabling real-time communication capabilities in your Blazor applications.
-
β Real-time WebRTC Communication Seamless voice and video calling powered by Telnyxβs browser-based WebRTC SDK.
-
βοΈ Automatic JS Module Bootstrapping Built-in JavaScript interop initialization with lazy loading and Blazor lifecycle integration.
-
π₯ High-Quality Audio & Video Calls Support for two-way audio and video with full control over microphone and webcam devices.
-
π Advanced Call Management Programmatic control over call lifecycle: initiate, answer, hangup, hold, resume, mute/unmute, deaf/undeaf, DTMF tones, and more.
-
π Device Enumeration & Dynamic Selection Enumerate and switch between available microphones, speakers, and cameras at runtime.
-
π‘ Custom Headers & Signaling Options Pass custom SIP headers during call setup for advanced routing or metadata requirements.
-
π ICE Server & TURN/STUN Configuration Fully configurable ICE server settings for NAT traversal and improved connectivity in restricted networks.
-
π’ Comprehensive Event Notifications Capture and handle all Telnyx WebRTC events: connection, media stream, call state, device changes, stats reports, and more.
dotnet add package Soenneker.Telnyx.Blazor.WebRtc
In your Program.cs
or startup file:
public static async Task Main(string[] args)
{
var builder = WebApplication.CreateBuilder(args);
// Register Telnyx WebRTC services
builder.Services.AddTelnyxWebRtcInteropAsScoped();
}
Add the TelnyxWebRtc component to your Blazor page:
@using Soenneker.Telnyx.Blazor.WebRtc
<TelnyxWebRtc @ref="_telnyxWebRtc" Options="@_options" />
@code {
private ITelnyxWebRtc? _telnyxWebRtc;
private TelnyxClientOptions _options;
protected override void OnInitialized()
{
_options = new TelnyxClientOptions
{
InitOptions = new TelnyxClientInitOptions
{
Login = "YOUR_TELNYX_LOGIN",
Password = "YOUR_TELNYX_PASSWORD"
// Set other properties as needed
}
};
}
}
The component provides various events you can subscribe to:
_telnyxWebRtc.OnInitialize += HandleInitialize;
_telnyxWebRtc.OnReady += HandleReady;
_telnyxWebRtc.OnError += HandleError;
_telnyxWebRtc.OnMessage += HandleMessage;
_telnyxWebRtc.OnNotification += HandleNotification;
_telnyxWebRtc.OnCallInitiated += HandleCallInitiated;
_telnyxWebRtc.OnCallAnswered += HandleCallAnswered;
_telnyxWebRtc.OnCallHeld += HandleCallHeld;
_telnyxWebRtc.OnCallResumed += HandleCallResumed;
_telnyxWebRtc.OnCallHangup += HandleCallHangup;
...
var callOptions = new TelnyxCallOptions
{
DestinationNumber = "+1234567890",
CallerName = "John Doe",
CallerNumber = "+1987654321"
};
await _telnyxWebRtc.Call(callOptions);
var answerOptions = new TelnyxAnswerOptions
{
AutoPlayAudio = true
};
await _telnyxWebRtc.Answer(answerOptions);
await _telnyxWebRtc.Hangup();