OdinRoom
Class to handle ODIN rooms.
A room is the virtual space where clients can communicate with each other.
Properties
roomHandle
The underlying room handle to interact with.
ownPeer
An instance of your own peer in the room.
gateway
The gateway URL used for authentication.
audioAutopilot
Indicates how and if medias will be added to the capture/playback mix automatically.
audioNode
The underlying object that receives mixed audio data from remote medias in the room.
audioConfig
The audio processing module settings of the room.
id
The name of the room.
customer
The identifier of the customer the room is assigned to.
userData
A byte array with arbitrary user data attached to the room.
connectionStatus
A tuple with current connection status of the room including a reason identifier for the last update.
peers
An array of current peers in the room.
medias
An array of current medias in the room.
delegate
An optional delegate with custom event callbacks.
remotePeers
An array of current remote peers in the room.
localMedias
An array of current local medias in the room, which can be used for capture.
remoteMedias
An array of current remote medias in the room, which can be used for playback.
isConnected
Indicates wether or not the room handle is connected.
isConnecting
Indicates wether or not the room handle is connecting.
isDisconnected
Indicates wether or not the room handle is disconnected.
Methods
init()
Initializes a new room instance.
init(gateway:)
Initializes a new room instance using a custom gateway URL.
deinit
Destroys the room handle and closes the connection to the server if needed.
join(token:)
Joins a room on an ODIN server and returns the ID of your own peer on success. This function takes a signed room token obtained externally that authorizes the client to establish the connection.
join(token:)
Joins a room on an ODIN server and returns the ID of your own peer on success. This function takes a signed room token obtained externally that authorizes the client to establish the connection.
leave()
Leaves the room and closes the connection to the server if needed.
updateAudioConfig(_:)
Updates the settings of the audio processing module for the room. This includes everything from noise reduction to smart voice activity detection.
updateGatewayUrl(_:)
Updates the gateway URL used for authentication.
setAudioAutopilotMode(_:)
Enables or disables the audio autopilot. This is a simple flag to control whether or not medias in the room will be added to the default capture/playback mix automatically.
updateUserData(userData:target:)
Updates the custom user data for either your own peer or the specified room itself. This data is synced between clients automatically, which allows storing of arbitrary information for each individual peer and even globally for the room if needed.
Note: Use this with target peer before calling OdinRoom.join
to set initial peer user data upon connect.
updatePeerUserData(userData:)
Updates the custom user data for your own peer. This data is synced between clients automatically.
Note: Use this before calling OdinRoom.join
to set initial peer user data upon connect.
updateRoomUserData(userData:)
Updates the custom user data for the current room. This data is synced between clients automatically.
updatePosition(x:y:)
Updates the two-dimensional position of your own peer. The server will use the specified coordinates for each
peer in the same room to apply automatic culling based on unit circles with a radius of 1.0
. This is ideal for
any scenario, where you want to put a large numbers of peers into the same room and make them only 'see' each
other while being in proximity. Additionally, you can use setPositionScale
to adjust the distance multiplier
for position updates if needed.
Note: Use this before calling OdinRoom.join
to set the initial peer position upon connect.
setPositionScale(scale:)
Sets the scaling used for all coordinates passed to updatePosition
. This allows adapting to the individual
needs of your game coorinate system if necessary. Only peers within a unit circle with a radius of 1.0
are
able to 'see' each other. When changing the position of a peer, the position must be scaled such as that the
maximum distance is one or less. The scaling can be done either manually or by setting the multiplicative scale
here.
Note: Please make sure that all of your client apps use the same scaling.
addMedia(type:)
Creates a new input stream of the specified type, adds it to the room and returns the media ID on success.
addMedia(audioConfig:)
Creates new audio input stream using the specified config, adds it to the room and returns the media ID on success. The new audio media can be used to transmit audio samples captured from a local microphone.
removeMedia(streamHandle:)
Removes the media instance matching the specified ID from the room and destroys it.
removeMedia(media:)
Removes the specified media instance from the room and destroys it.
sendMessage(data:targetIds:)
Sends a message with arbitrary data to all other peers in the same room. Optionally, you can provide a list of target IDs to send the message to specific peers only.
hash(into:)
Hashes the essential components of the room by feeding them into the given hasher.
==(_:_:)
Returns a value indicating whether two type-erased hashable instances wrap the same room.