FNVoice Facade
FV (namespace FigNet.Voice, class FNVoice.cs) is the Unity-client static facade for the FnVoice module -
connect to the voice server, authenticate, and read connection/room state. There is no separate server-side
static facade for FnVoice: the server side only relays room events and voice packets via FigNet/Entangle
handlers, it does not expose an equivalent FV-style API.
A sibling class, FNVoice_Internals, holds cross-cutting state (channel ids, AoI/room-property mirrors, auth
bookkeeping) that other FnVoice internals read. It isn't the intended public entry point - use FV and
FNVoiceConfig instead.
Mic capture/recording is not controlled through FV at all - it lives on the VoiceChatRecorder component
and the encode/decode pipeline described in
FnVoice - End-to-End Audio Pipeline. FV only manages the session (connect,
auth, room/lobby handles); it does not expose start/stop-mic methods itself.
Lifecycle
public static void Initialize()
Wires up serialization, creates Room/Lobby, and hooks internal event handlers. Call once before connecting.
public static void SetConfig(FNVoiceConfig config)
Applies a FNVoiceConfig (app id, device id/display name, auth mode/credential, room properties) to the
module's internal state. Call before Connect().
public static void Connect()
Resolves the peer config from Config, creates the client socket (or reconnects an existing one) and connects
to the FnVoice server. On successful connect, session authentication is kicked off automatically.
public static void ReconnectAndJoin()
Marks a reconnect-in-progress and calls Connect() again; used for the auto-reconnect path.
public static void Disconnect()
Disconnects the socket if currently connected.
Identity & auth
public static void SetDeviceIdentity(string deviceId, string displayName = null)
Overrides the device id / display name used for authentication (device auth mode).
public static void SetAuthToken(string token, string deviceId = null, string displayName = null)
Switches auth mode to AuthMode.ExternalToken with the given token, optionally overriding device id/display
name at the same time.
public static FNVoiceConfig Config
The config applied via SetConfig; null until then.
public static bool IsAuthenticated { get; }
public static string UserId { get; }
public static string SessionId { get; }
Populated once the post-connect authentication handshake succeeds; reset to false/null on disconnect.
Connection state
public static bool IsConnected { get; }
public static IClientSocket Socket { get; }
public static bool IsFallbackProtocolDetected { get; }
IsFallbackProtocolDetected flips true once enough reconnect attempts have occurred and
Config.IsFallbackProtocolEnabled is set, after which Connect() targets the fallback port/transport.
public static int GetPing()
Returns Socket.Ping, or -1 if there is no socket yet.
Room / player / game state
public static VoipRoom Room { get; }
public static VoipLobby Lobby { get; }
Entry points to room and lobby functionality; their own members live outside this facade file.
public static bool IsMasterClient { get; }
public static bool IsInGame { get; set; }
public static uint MyTeamId { get; set; }
public static uint MyPlayerId { get; set; }
Events
public static event Action OnConnected;
public static event Action OnDisconnected;
public static event Action<PeerStatus> OnNetworkStatusChanged;
public static event Action<RoomResponseCode> OnRoomAutoReJoinStatus;
public static event Action<AuthResponseCode> OnAuthenticationCompleted;
public static event Action<DeviceAuthResponseCode> OnAuthenticated;
public static Action<bool> OnMasterClientUpdate;
OnAuthenticationCompleted (AuthResponseCode) is the current auth-completed event; OnAuthenticated
(DeviceAuthResponseCode) is kept as a legacy/compat event and is fed via an internal response-code mapping
alongside it - both fire together on the same authentication attempt.
Logging & diagnostics
public static readonly ModuleLog Log;
public static LoggingLevel LoggingLevel { get; set; }
public static Action<string, string, LoggingLevel> LogMessageReceived;
Log is the module's zero-alloc logging facade (FV.Log.Log(...)); LoggingLevel is a compatibility wrapper
over Log.MinLevel using the module's own LoggingLevel enum (None, Info, Debug, Error, All).
public static void Diagnostic(string area, string message, LogType level = LogType.Info)
Always-on diagnostics channel - writes directly to the Unity console regardless of Log's level, for
periodic health summaries and one-shot lifecycle/fault events (not per-frame use).
See also
- FnVoice - End-to-End Audio Pipeline - where mic capture, encode/decode, and playback actually happen (outside this facade).
- Using FnVoice with a different networking stack - the
IVoiceTransport/IVoiceSessionseam this facade sits above when FigNet is the transport.