SimliClient class

Represents a client for interacting with the Simli API and managing WebRTC connections, including video rendering, peer connections, and data channels.

Constructors

SimliClient({required SimliClientConfig clientConfig, required Logger log})
Creates a new SimliClient instance.

Properties

audioLevelNotifier ValueNotifier<double>
Notifies listeners with audio level of the avatar.
getter/setter pair
audioLEvelTimer Timer?
Timer for monitoring audio levels.
getter/setter pair
candidateCount int
The number of ICE candidates found.
getter/setter pair
clientConfig SimliClientConfig
client config for the session
getter/setter pair
config SimliClientConfig
Gets the client configuration
no setter
connectionTimeOutTimer Timer?
Timer for monitoring audio levels.
getter/setter pair
errorReason String?
it will hold the reason for the error
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
isConnected bool
Utility method to check connection status
no setter
isSpeaking bool
Gets whether the user is currently speaking.
getter/setter pair
isSpeakingNotifier ValueNotifier<bool>
Notifies listeners of changes in whether the user is speaking.
getter/setter pair
lastSendTime int
store the time of last send time of data
getter/setter pair
log ↔ Logger
Logger for the login of the data
getter/setter pair
onConnection VoidCallback?
A callback for handling connection events.
getter/setter pair
onDisconnected VoidCallback?
A callback for handling disconnection events.
getter/setter pair
onFailed ↔ void Function(SimliError error)?
A callback for handling connection failed events.
getter/setter pair
peerConnection ↔ RTCPeerConnection?
The WebRTC peer connection.
getter/setter pair
prevCandidateCount int
Tracks the previous ICE candidate count.
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
sessionInitialized bool
it will be true if session is initialized
getter/setter pair
state SimliState
Gets current state of the client.
getter/setter pair
stateNotifier ValueNotifier<SimliState>
Notifies listeners of changes to the client's state.
getter/setter pair
videoRenderer ↔ RTCVideoRenderer?
The video renderer used for displaying video streams.
getter/setter pair
webSocket ↔ WebSocket?
websocket connection for communication
getter/setter pair

Methods

cleanup() Future<void>
it will cleanup the current resource
clearBuffer() → void
it will clear the current audio buffer on server
clearTimeouts() → void
it will clear connection timeout
close() Future<void>
Closes the peer connection, data channels, video renderer, and timers. Ensures all resources are properly released.
createRTCPeerConnection() Future<void>
Creates a WebRTC peer connection and sets up listeners.
getIceServers({required int maxRetry, required Duration retryDelay, required String apiKey, required Duration requestTimeout}) Future
Returns a list of ICE servers.
handleConnectionFailure(String reason) → void
it will handle connection failure
handleConnectionTimeout() → void
it will handle connection timeout
handleDisconnection() → void
handle disconnection of the webrtc connection
initializeSession() Future<void>
Initializes a session by sending metadata to a remote API.
logException(dynamic data) → void
it will log using serve method
logInfo(dynamic data) → void
it will log using info method
logSuccess(dynamic data) → void
it will log using info method
monitorAudioPlaying(RTCPeerConnection connection, MediaStreamTrack audioTrack) Future<void>
it will monitor audio playing on audio track
negotiate() Future<void>
Negotiates a WebRTC connection by creating an offer, setting the local description, gathering ICE candidates, and exchanging session details with the server.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
sendAudioData(Uint8List audioData) → void
Sends audio data over the data channel.
setupPeerConnectionListener() → void
Sets up listeners for WebRTC peer connection events.
start({int retryAttempt = 1}) Future<void>
Starts the WebRTC session by creating the peer connection, adding data channels, and negotiating.
toString() String
A string representation of this object.
inherited
waitForIceGathering() Future<void>
Waits for the ICE gathering process to complete.

Operators

operator ==(Object other) bool
The equality operator.
inherited