ODIN Web SDK Reference Documentation Links
This document provides links to all the ODIN types available in the Web SDK.
Class
OdinClient Class
Definition
- Name
- OdinClient
- Link to documentation
- https://www.4players.io/odin/sdk/web/classes/odinclient
export class OdinClient
Class providing static methods to handle ODIN client connections.
Properties
Name | Description |
---|---|
public config: IOdinClientSettings | Global settings for ODIN connections. |
public connectionState: OdinConnectionState | The current state of the main stream connection. |
public rooms: OdinRoom[] | An array of available OdinRoom instances. |
Methods
Name | Description |
---|---|
public addEventListener(eventName: Event, handler: IOdinClientEvents[Event]): void | Registers to client events from IOdinClientEvents . |
public disconnect(state: OdinConnectionState): void | Disconnects from all rooms and stops all audio handling. |
public initRoom(token: string, gateway?: string, audioContext?: AudioContext): Promise<OdinRoom> | Authenticates against the ODIN server and returns an OdinRoom instance for the first room set in the specified token. This function accepts an optional AudioContext parameter for audio capture. The AudioContext interface is a part of the Web Audio API that represents an audio-processing graph, which can be used to control and manipulate audio signals in web applications. If the AudioContext is not provided or explicitly set to undefined , we will try to create one internally. |
public initRooms(token: string, gateway?: string, audioContext?: AudioContext): Promise<OdinRoom[]> | Authenticates against the ODIN server and returns OdinRoom instances for all rooms set in the specified token. This function accepts an optional AudioContext parameter for audio capture. The AudioContext interface is a part of the Web Audio API that represents an audio-processing graph, which can be used to control and manipulate audio signals in web applications. If the AudioContext is not provided or explicitly set to undefined , we will try to create one internally. |
OdinMedia Class
Definition
- Name
- OdinMedia
- Link to documentation
- https://www.4players.io/odin/sdk/web/classes/odinmedia
export class OdinMedia
Class describing a single media stream inside an OdinRoom
.
Properties
Name | Description |
---|---|
public active: boolean | Indicates wether or not the media is currently sending/receiving data. |
public id: number | The ID of the media. |
public paused: boolean | Indicates wether or not the media is paused. |
public peerId: number | The ID of the peer that owns the media. |
public remote: boolean | Indicates wether or not the media belongs to a remote peer. |
public started: boolean | Indicates whether or not the media is registered in the audio service instance (e.g. started). |
public volume: number | The individual playback volume of the media stream. |
Methods
Name | Description |
---|---|
public addEventListener(eventName: Event, handler: IOdinMediaEvents[Event]): void | Registers to media events from IOdinMediaEvents . |
public changeVolume(volume: number): void | Changes the playback volume of the media. |
public pause(): Promise<void> | Paused the media stream on the server to stop receiving data on it. |
public resume(): Promise<void> | Paused the media stream on the server to start receiving data on it. |
public start(): Promise<void> | Starts the media stream by initiating the encoder/decoder and adding it to the room if it belongs to the local peer. |
public stop(): Promise<void> | Stops the media stream by terminating the encoder/decoder and removing it from the room if it belongs to the local peer. |
OdinPeer Class
Definition
- Name
- OdinPeer
- Link to documentation
- https://www.4players.io/odin/sdk/web/classes/odinpeer
export class OdinPeer
Class describing a single peer inside an OdinRoom
.
Properties
Name | Description |
---|---|
public data: Uint8Array | The arbitrary user data of the peer. |
public id: number | The ID of the peer. |
public medias: Map<number><OdinMedia> | A list of media instances owned by the peer. |
public remote: boolean | Indicates, whether the peer is a remote peer or not. |
public userId: string | The identifier of the peer. |
Methods
Name | Description |
---|---|
public addEventListener(eventName: Event, handler: IOdinPeerEvents[Event]): void | Registers to peer events from IOdinPeerEvents . |
public addMedia(media: OdinMedia): void | Adds a media to the list of active medias and starts decoding. |
public createMedia(): OdinMedia | Creates a local media, configures audio capture/playback and returns the new OdinMedia instance. |
public removeMedia(media: OdinMedia): void | Removes a media from the list of active medias and stops decoding. |
public removeMediaById(id: number): void | Removes a media from the list of active medias by the given ID and stops decoding. |
public sendMessage(message: Uint8Array): Promise<void> | Sends a message with arbitrary data to this peer. |
public startMedias(mediaIds?: number[]): Promise<void> | Starts all active medias or a list of specific active medias. |
public stopMedias(mediaIds?: number[]): Promise<void> | Stops all active medias or a list of specific active medias. |
public update(): Promise<void> | Sends user data of the peer to the server. |
OdinRoom Class
Definition
- Name
- OdinRoom
- Link to documentation
- https://www.4players.io/odin/sdk/web/classes/odinroom
export class OdinRoom
Class describing an OdinRoom
.
Properties
Name | Description |
---|---|
public connectionState: OdinConnectionState | The current state of the room stream connection. |
public customer: string | The customer identifier this room is assigned to. |
public data: Uint8Array | The arbitrary user data of the room. |
public id: string | The ID of the room. |
public ownPeer: OdinPeer | An instance of your own OdinPeer in the room. |
public position: any | The current three-dimensional position of our own OdinPeer in the room. |
public remotePeers: Map<number><OdinPeer> | A map of all remote OdinPeer instances in the room using the peer ID as index. |
public serverAddress: string | The address of the voice server this room is living on. |
Methods
Name | Description |
---|---|
public addEventListener(eventName: OdinEvent, handler: IOdinRoomEvents[OdinEvent]): void | Register to peer events from IOdinRoomEvents . |
public changeMediaStream(mediaStream: MediaStream): Promise<void> | Changes the active capture stream (e.g. when switching to another input device). |
public changeVolume(volume: number): void | Change the global master volume for the room (should be between 0 and 2). |
public createMedia(mediaStream: MediaStream, audioSettings?: IOdinAudioSettings): Promise<OdinMedia> | Creates a new local media using the specified stream. |
public disableVAD(): void | Disables RNN-based voice activity detection. |
public disableVolumeGate(): void | Disables RNN-based voice activity detection. |
public enableVAD(): void | Enables RNN-based voice activity detection. |
public enableVolumeGate(): void | Enables RNN-based voice activity detection. |
public flushOwnPeerDataUpdate(): Promise<void> | Sends updated user data of your own peer to the server. |
public getAudioSettings(): undefined | IOdinAudioSettings | Returns the current voice processing config for VAD and volume gate. |
public getMediaById(id: number): undefined | OdinMedia | Returns the OdinMedia instance matching the specified ID. |
public getPeerById(id: number): undefined | OdinPeer | Returns the OdinPeer instance matching the specified ID. |
public join(userData?: Uint8Array, position?: any): Promise<OdinPeer> | Joins the room and returns your own peer instance after the room was successfully joined. |
public sendMessage(message: Uint8Array, targetPeerIds?: number[]): Promise<void> | Sends a message with arbitrary data to all peers in the room or optionally to a list of specified peers. |
public setPosition(offsetX: number, offsetY: number, offsetZ: number): void | Updates the three-dimensional position of our own OdinPeer in the room to apply server-side culling. |
public startVADMeter(): void | Enables emitting of RNN-based voice activity detection statistics. |
public stopVADMeter(): void | Disables emitting of RNN-based voice activity detection statistics. |
public updateVADThresholds(attackProbability: number, releaseProbability?: number): void | Updates thresholds for vice activity detection (between 0 and 1). |
public updateVolumeGateThresholds(attackLoudness: number, releaseLoudness?: number): void | Updates thresholds for the input volume gate (between -90 and 0). |
Interface
IOdinAudioSettings Interface
Definition
- Name
- IOdinAudioSettings
- Link to documentation
- https://www.4players.io/odin/sdk/web/interfaces/iodinaudiosettings
export interface IOdinAudioSettings
Interface describing audio settings to be applied on connect.
Properties
Name | Description |
---|---|
public voiceActivityDetection: boolean | Enable or disable RNN-based voice activity detection. |
public voiceActivityDetectionAttackProbability: number | Voice probability value when the VAD should engage |
public voiceActivityDetectionReleaseProbability: number | Voice probability value when the VAD should disengage |
public volumeGate: boolean | Enables or disables the input volume gate |
public volumeGateAttackLoudness: number | Root mean square power (dBFS) when the volume gate should engage |
public volumeGateReleaseLoudness: number | Root mean square power (dBFS) when the volume gate should disengage |
IOdinAudioStats Interface
Definition
- Name
- IOdinAudioStats
- Link to documentation
- https://www.4players.io/odin/sdk/web/interfaces/iodinaudiostats
export interface IOdinAudioStats
Interface describing encoder/decoder statistics from the audio worker.
Properties
IOdinAudioStatsEventPayload Interface
Definition
- Name
- IOdinAudioStatsEventPayload
- Link to documentation
- https://www.4players.io/odin/sdk/web/interfaces/iodinaudiostatseventpayload
export interface IOdinAudioStatsEventPayload
Interface describing the payload of an OdinAudioStatsEvent
.
Properties
Name | Description |
---|---|
public room: OdinRoom | The OdinRoom instance the stats ere coming from. |
public stats: IOdinAudioStats | The internal Opus encoder/decoder stats. |
IOdinClientEvents Interface
Definition
- Name
- IOdinClientEvents
- Link to documentation
- https://www.4players.io/odin/sdk/web/interfaces/iodinclientevents
export interface IOdinClientEvents
Interface describing possible media events.
Properties
Name | Description |
---|---|
public ConnectionStateChanged: OdinConnectionStateChangedEvent | Main stream connection state updates. |
IOdinClientSettings Interface
Definition
- Name
- IOdinClientSettings
- Link to documentation
- https://www.4players.io/odin/sdk/web/interfaces/iodinclientsettings
export interface IOdinClientSettings
Interface describing custom options for ODIN clients.
Properties
Name | Description |
---|---|
public gatewayUrl: string | The URL of the ODIN gateway to use. |
IOdinConnectionStateChangedEventPayload Interface
Definition
- Name
- IOdinConnectionStateChangedEventPayload
- Link to documentation
- https://www.4players.io/odin/sdk/web/interfaces/iodinconnectionstatechangedeventpayload
export interface IOdinConnectionStateChangedEventPayload
Interface describing the payload of an OdinConnectionStateChangedEvent
.
Properties
Name | Description |
---|---|
public newState: OdinConnectionState | Current state of the connection. |
public oldState: OdinConnectionState | Previous state of the connection. |
IOdinEvent Interface
Definition
- Name
- IOdinEvent
- Link to documentation
- https://www.4players.io/odin/sdk/web/interfaces/iodinevent
export interface IOdinEvent
Interface extending default JavaScript events with custom information.
Properties
Name | Description |
---|---|
public payload: T | Custom payload of the event (see IOdin*Payload interfaces). |
IOdinMediaActivityChangedEventPayload Interface
Definition
- Name
- IOdinMediaActivityChangedEventPayload
- Link to documentation
- https://www.4players.io/odin/sdk/web/interfaces/iodinmediaactivitychangedeventpayload
export interface IOdinMediaActivityChangedEventPayload
Interface describing the payload of an OdinMediaActivityChangedEvent
.
Properties
Name | Description |
---|---|
public media: OdinMedia | The media that was updated. |
public peer: OdinPeer | The peer that owns the media. |
public room: OdinRoom | The room the media is added to. |
IOdinMediaEvents Interface
Definition
- Name
- IOdinMediaEvents
- Link to documentation
- https://www.4players.io/odin/sdk/web/interfaces/iodinmediaevents
export interface IOdinMediaEvents
Interface describing possible media events.
Properties
Name | Description |
---|---|
public Activity: OdinMediaActivityChangedEvent | The media is sending/receiving data. |
IOdinMediaStartedStoppedEventPayload Interface
Definition
- Name
- IOdinMediaStartedStoppedEventPayload
- Link to documentation
- https://www.4players.io/odin/sdk/web/interfaces/iodinmediastartedstoppedeventpayload
export interface IOdinMediaStartedStoppedEventPayload
Interface describing the payload of an OdinMediaStartedStoppedEvent
.
Properties
Name | Description |
---|---|
public media: OdinMedia | The media that was added/removed. |
public peer: OdinPeer | The peer that owns the media. |
public room: OdinRoom | The room where the media was added/removed. |
IOdinMessageReceivedEventPayload Interface
Definition
- Name
- IOdinMessageReceivedEventPayload
- Link to documentation
- https://www.4players.io/odin/sdk/web/interfaces/iodinmessagereceivedeventpayload
export interface IOdinMessageReceivedEventPayload
Interface describing the payload of an OdinMessageReceivedEvent
.
Properties
Name | Description |
---|---|
public message: Uint8Array | A byte array with the message. |
public room: OdinRoom | The room where the message was received. |
public senderId: number | The ID of the peer that sent the message (might not be in proximity). |
IOdinPeerDataChangedEventPayload Interface
Definition
- Name
- IOdinPeerDataChangedEventPayload
- Link to documentation
- https://www.4players.io/odin/sdk/web/interfaces/iodinpeerdatachangedeventpayload
export interface IOdinPeerDataChangedEventPayload
Interface describing the payload of an OdinPeerDataChangedEvent
.
Properties
Name | Description |
---|---|
public peer: OdinPeer | The updated OdinPeer instance. |
public room: OdinRoom | The room where the peer was updated. |
IOdinPeerEvents Interface
Definition
- Name
- IOdinPeerEvents
- Link to documentation
- https://www.4players.io/odin/sdk/web/interfaces/iodinpeerevents
export interface IOdinPeerEvents
Interface describing possible peer events.
Properties
Name | Description |
---|---|
public MediaActivity: OdinMediaActivityChangedEvent | A media owned by the peer is sending/receiving data. |
public MediaStarted: OdinMediaStartedStoppedEvent | Peer added a new media stream. |
public MediaStopped: OdinMediaStartedStoppedEvent | Peer removed a media stream. |
public MessageReceived: OdinMessageReceivedEvent | Peer sent a message with arbitrary data. |
public UserDataChanged: OdinPeerDataChangedEvent | Peer updated its user data. |
IOdinPeerJoinedLeftEventPayload Interface
Definition
- Name
- IOdinPeerJoinedLeftEventPayload
- Link to documentation
- https://www.4players.io/odin/sdk/web/interfaces/iodinpeerjoinedlefteventpayload
export interface IOdinPeerJoinedLeftEventPayload
Interface describing the payload of an OdinPeerJoinedLeftEvent
.
Properties
Name | Description |
---|---|
public peer: OdinPeer | The peer that joined/left. |
public room: OdinRoom | The room the peer joined/left. |
IOdinRoomDataChangedEventPayload Interface
Definition
- Name
- IOdinRoomDataChangedEventPayload
- Link to documentation
- https://www.4players.io/odin/sdk/web/interfaces/iodinroomdatachangedeventpayload
export interface IOdinRoomDataChangedEventPayload
Interface describing the payload of an OdinRoomDataChangedEvent
.
Properties
Name | Description |
---|---|
public room: OdinRoom | The updated OdinRoom instance. |
IOdinRoomEvents Interface
Definition
- Name
- IOdinRoomEvents
- Link to documentation
- https://www.4players.io/odin/sdk/web/interfaces/iodinroomevents
export interface IOdinRoomEvents
Interface describing possible room events.
Properties
IOdinRoomJoinedLeftEventPayload Interface
Definition
- Name
- IOdinRoomJoinedLeftEventPayload
- Link to documentation
- https://www.4players.io/odin/sdk/web/interfaces/iodinroomjoinedlefteventpayload
export interface IOdinRoomJoinedLeftEventPayload
Interface describing the payload of an OdinRoomJoinedLeftEvent
.
Properties
Name | Description |
---|---|
public room: OdinRoom | The room that was joined/left. |
Type
OdinAudioStatsEvent Type
Definition
- Name
- OdinAudioStatsEvent
- Link to documentation
- https://www.4players.io/odin/sdk/web/types/odinaudiostatsevent
OdinConnectionStateChangedEvent Type
Definition
- Name
- OdinConnectionStateChangedEvent
- Link to documentation
- https://www.4players.io/odin/sdk/web/types/odinconnectionstatechangedevent
OdinMediaActivityChangedEvent Type
Definition
- Name
- OdinMediaActivityChangedEvent
- Link to documentation
- https://www.4players.io/odin/sdk/web/types/odinmediaactivitychangedevent
OdinMediaStartedStoppedEvent Type
Definition
- Name
- OdinMediaStartedStoppedEvent
- Link to documentation
- https://www.4players.io/odin/sdk/web/types/odinmediastartedstoppedevent
OdinMessageReceivedEvent Type
Definition
- Name
- OdinMessageReceivedEvent
- Link to documentation
- https://www.4players.io/odin/sdk/web/types/odinmessagereceivedevent
OdinPeerDataChangedEvent Type
Definition
- Name
- OdinPeerDataChangedEvent
- Link to documentation
- https://www.4players.io/odin/sdk/web/types/odinpeerdatachangedevent
OdinPeerJoinedLeftEvent Type
Definition
- Name
- OdinPeerJoinedLeftEvent
- Link to documentation
- https://www.4players.io/odin/sdk/web/types/odinpeerjoinedleftevent
OdinRoomDataChangedEvent Type
Definition
- Name
- OdinRoomDataChangedEvent
- Link to documentation
- https://www.4players.io/odin/sdk/web/types/odinroomdatachangedevent
OdinRoomJoinedLeftEvent Type
Definition
- Name
- OdinRoomJoinedLeftEvent
- Link to documentation
- https://www.4players.io/odin/sdk/web/types/odinroomjoinedleftevent
Type alias
OdinConnectionState Type alias
Definition
- Name
- OdinConnectionState
- Link to documentation
- https://www.4players.io/odin/sdk/web/types/odinconnectionstate
export type OdinConnectionState
Enum defining all possible connection states of the ODIN client.