nimeet Docs
中文

C# (.NET) SDK Reference

Windows .NET SDK public interface, installation and capability notes.

Interface sections generated from the public SDK definitions

Version v1.1.0 · Updated 2026-10-26 · revision 1

The C# (.NET) SDK has the RtcEngine + IRtcEngineEventHandler shape; it is isomorphic to the Unity SDK but targets desktop .NET (WPF / WinForms / console services).

Prerequisites

  • .NET 8 SDK (net8.0), Windows 10 1809+ (the current declaration reference version comes from the Windows C# wrapper).
  • System camera/microphone permissions.
  • An appId and a token service (see Enable Services and Get Credentials).

Installation

xml
<!-- planned coordinates, not published to NuGet yet -->
<PackageReference Include="Nimeet.Rtc" Version="0.1.0" />

Get a token

Your server issues the token (POST /v1/tokens); the desktop client only receives the string. Never put appCustomerSecret into a configuration file.

csharp
var response = await httpClient.GetFromJsonAsync<TokenResponse>("/api/rtc-token?channel=weekly-sync&uid=10001");
engine.JoinChannel(response.RtcToken, "weekly-sync", 10001, options);

Join a channel

csharp
using Nimeet.Rtc;

public sealed class MeetingController : IRtcEngineEventHandler
{
    private readonly IRtcEngine engine;

    public MeetingController(string appId)
    {
        engine = RtcEngine.CreateAgoraRtcEngine();
        engine.Initialize(new RtcEngineContext { AppId = appId, EventHandler = this });
        engine.SetChannelProfile(ChannelProfileType.ChannelProfileLiveBroadcasting);
        engine.EnableVideo();
        engine.StartPreview();
    }

    public void Join(string token, uint uid)
    {
        var options = new ChannelMediaOptions
        {
            ClientRoleType = ClientRoleType.ClientRoleBroadcaster,
            AutoSubscribeAudio = true,
            AutoSubscribeVideo = true,
        };
        var code = engine.JoinChannel(token, "weekly-sync", uid, options);
        if (code < 0) throw new RtcException(code);
    }

    public void OnJoinChannelSuccess(RtcConnection connection, int elapsed) { }
    public void OnUserJoined(RtcConnection connection, uint remoteUid, int elapsed) { }
    public void OnUserOffline(RtcConnection connection, uint remoteUid, UserOfflineReasonType reason) { }
    public void OnTokenPrivilegeWillExpire(string token) => engine.RenewToken(FetchFreshToken());
    public void OnError(int err, string msg) => Console.Error.WriteLine($"rtc {err}: {msg}");
}

Publishing and subscribing

csharp
engine.MuteLocalAudioStream(true);
engine.MuteLocalVideoStream(true);
engine.EnableLocalVideo(false);
engine.UpdateChannelMediaOptions(options);

Screen sharing: GetScreenCaptureSources → StartScreenCaptureByWindowId / StartScreenCaptureByScreenRect; in WPF the remote picture is usually drawn into an Image/D3DImage through the render callback the plugin provides.

Events

IRtcEngineEventHandler: OnJoinChannelSuccess, OnUserJoined, OnUserOffline, OnFirstRemoteVideoDecoded, OnTokenPrivilegeWillExpire, OnError, OnConnectionStateChanged.

Error handling

  • Synchronous methods return int; 0 means success and a negative value is an Agora error number;
  • Asynchronous errors arrive through OnError;
  • Unimplemented capabilities return -4 (ERR_NOT_SUPPORTED).

Troubleshooting

SymptomCauseHandling
DllNotFoundExceptionThe native library was not copied with the packageAdd runtimes/win-x64/native to the output
Updating the UI inside a callback throwsCross-thread accessUse Dispatcher.Invoke
Capture failsSystem privacy settingsAllow desktop apps to use the camera/microphone in Settings
A 64-bit process loads a 32-bit libraryPlatform target mismatchUse x64 everywhere
Token expiry goes unnoticedOnTokenPrivilegeWillExpire is not handledRenew the token and call RenewToken

Next steps

Platform information

Itemvalue
PlatformC#(.NET)
LanguageC#
SDK packageNimeet.Rtc
Interface versionunknown
Compatible Agora APIAgora csharp API

The public interfaces are aligned with the Agora csharp API; installation and runtime requirements are listed under Prerequisites above.

Availability

This platform's SDK: Generally available. The examples use the public API; runtime capability follows the published SDK package.

join-channel flow

The method names, parameter types and return values match the API reference for the same platform. Where a method has several overloads, the most common one is shown here; see the API reference for all overloads.

StepInterfaceMethodOverload count
Join a channel__unattributed__JoinChannel1
Leave a channel__unattributed__LeaveChannel1
subscribe to remote media__unattributed__MuteRemoteAudioStream1
switch roles__unattributed__SetClientRole1
bind the local video__unattributed__SetupLocalVideo1
enable video and local preview__unattributed__StartPreview1
Create instance / initializeILocalSpatialAudioEngineInitialize1
Renew the TokenIRtcEngineRenewToken1
Channel scenariosIRtcEngineSetChannelProfile1
typescript
JoinChannel(token: string, channelId: string, info?: string, uid?: uint): int
LeaveChannel(): int
MuteRemoteAudioStream(uid: uint, mute: bool): int
SetClientRole(role: CLIENT_ROLE_TYPE): int
SetupLocalVideo(canvas: VideoCanvas): int
StartPreview(): int
Initialize(): int
RenewToken(token: string): int
SetChannelProfile(profile: CHANNEL_PROFILE_TYPE): int

Events and callbacks

Interfaceevent namelistener parameters
IMediaPlayerSourceObserverOnPlayerCacheStatspublic virtual void OnPlayerCacheStats(CacheStatistics stats) { }
IMediaPlayerSourceObserverOnPlayerPlaybackStatspublic virtual void OnPlayerPlaybackStats(PlayerPlaybackStats stats) { }
IRtcEngineEventHandlerOnExtensionErrorWithContextpublic virtual void OnExtensionErrorWithContext(ExtensionContext context, int error, string message){}
IRtcEngineEventHandlerOnExtensionEventWithContextpublic virtual void OnExtensionEventWithContext(ExtensionContext context, string key, string value){}
IRtcEngineEventHandlerOnExtensionStartedWithContextpublic virtual void OnExtensionEventWithContext(ExtensionContext context, string key, string value){ }
IRtcEngineEventHandlerOnExtensionStoppedWithContextpublic virtual void OnExtensionStoppedWithContext(ExtensionContext context){ }

Error codes

Constantvalue
ERR_ABORTED20
ERR_ADM_GENERAL_ERROR1005
ERR_ADM_INIT_PLAYOUT1008
ERR_ADM_INIT_RECORDING1011
ERR_ADM_START_PLAYOUT1009
ERR_ADM_START_RECORDING1012
ERR_ADM_STOP_PLAYOUT1010
ERR_ADM_STOP_RECORDING1013
ERR_ALREADY_IN_USE19
ERR_BITRATE_LIMIT115
ERR_BUFFER_TOO_SMALL6
ERR_CLIENT_IS_BANNED_BY_SERVER123
ERR_CONNECTION_INTERRUPTED111
ERR_CONNECTION_LOST112
ERR_DATASTREAM_DECRYPTION_FAILED122
ERR_DECRYPTION_FAILED120
ERR_ENCRYPTED_STREAM_NOT_ALLOWED_PUBLISH130
ERR_FAILED1
ERR_INIT_NET_ENGINE21
ERR_INVALID_APP_ID101
ERR_INVALID_ARGUMENT2
ERR_INVALID_CHANNEL_NAME102
ERR_INVALID_STATE8
ERR_INVALID_TOKEN110
ERR_INVALID_USER_ACCOUNT134
ERR_INVALID_USER_ID121
ERR_JOIN_CHANNEL_REJECTED17
ERR_LEAVE_CHANNEL_REJECTED18
ERR_LOAD_MEDIA_ENGINE1001
ERR_NOT_INITIALIZED7
ERR_NOT_IN_CHANNEL113
ERR_NOT_READY3
ERR_NOT_SUPPORTED4
ERR_NO_PERMISSION9
ERR_NO_SERVER_RESOURCES103
ERR_OK0
ERR_REFUSED5
ERR_RESOURCE_LIMITED22
ERR_SET_CLIENT_ROLE_NOT_AUTHORIZED119
ERR_SIZE_TOO_LARGE114
ERR_STREAM_MESSAGE_TIMEOUT117
ERR_TIMEDOUT10
ERR_TOKEN_EXPIRED109
ERR_TOO_MANY_DATA_STREAMS116
ERR_VDM_CAMERA_NOT_AUTHORIZED1501
IRtcEnginenull

the platform REST layer uses REST error codes;the SDK layer maps connection/authentication failures to Agora error numbers, for the mapping table see SDK error identifiers per platform。

Generated by the documentation build pipeline · 2026-10-31 01:24:02 UTC · Documentation center v1.1.0.

Content follows the public API definitions.

ni-meet is a self-hosted RTC PaaS with a LiveKit-based media plane (Apache-2.0) and an Agora-compatible API.