Skip to main content

Basic Concepts

ODIN is a client server platform. Servers are hosted by 4Players, but can also be hosted by clients. The whole system is stateless and scalable. There are no databases keeping track of everything, instead everything just relies on stateless connections and some tokens that are used during authentication.

info

In the following diagrams we use these words frequently.

Local: For the local client (i.e. you as a developer testing your current build)

Server: The ODIN server hosted by 4Players or hosted by yourself on your own infrastructure or the cloud

Remote: All other clients connected to the same server/room, i.e. your colleagues.

Topology

This diagram outlines the basic structure of two clients connected to an ODIN server. Client 1 has joined two rooms listening and talking and Client 2 has also joined room 2 but is just listening there.

Every client connects an ODIN server and authenticates with an access token and joins a room. Once the client has joined a room, he is a peer inside the ODIN room. Every peer can add media to that room, linked to a physical device like a microphone. Clients can join multiple rooms at the same time and can add multiple media streams at the same time.

warning

ODIN rooms work independently of each other. This means that each client is a different peer in every room, having a different peer id. Also, you cannot use the same media stream for multiple rooms at once, but you have to create a new one for each room.

info

Every peer receives the media streams of the other peers connected to the same room, but are not required to add their own media. Spectators will want to listen but not talking themselves. A muted peer for example also does not have a media.

Connecting to Server

The first step is to connect to a server and a room. If you are using one of our high level SDKs like Unity or Unreal joining a room is all you have to do. The SDK handles authentication and server connection for you.

Once the connection is established and the room has joined an event is sent to all other peers in the same room: PeerJoined. This allows you to update your UI for example like showing a list of peers that are within a room.

The client who joined the room will receive a RoomJoin and RoomJoined event. If a user clicks a button to join a room, you can use the RoomJoin event to start showing a loading indicator and hiding it once RoomJoined has been triggered.

Event summary

LocalRemoteDescription

OnRoomJoin

Triggered if user started to join a room

OnRoomJoined

OnPeerJoined

Triggered if user joined a room

ODIN does not require any bookkeeping. A room is created automatically for the first connection and will be removed whenever the last user left the room. You join a room by calling the

JoinRoom

method of the

OdinHandler

instance in your scene.

Joining a room
class MyVoiceHandler: MonoBehaviour
{
public string RoomName = "default";

// Start is called before the first frame update
void Start()
{
OdinHandler.Instance.JoinRoom(RoomName);
}
}

Starting a media

As defined above, every peer connected to a room can (but does not have to) add a media, i.e. a stream connected to the peers' input device, e.g. a microphone. Please note: Every peer can add multiple media to the same room (i.e. audio and video). In Contrary, you can not use the same media twice, e.g. for 2 different rooms.

Adding a local media will trigger the MediaAdded event on remove peers.

Event summary

Stopping a media

Users can mute their audio streams, in this case, the media stream should be stopped, so that no data is captured and to ODIN servers. Of course, also leaving a room can lead to stopped media.

The MediaStopped event will be triggered once the request media has been deleted on the server.

Event summary

Updating Peer User Data

Every peer in Unity can store arbitrary information as user data. When local user data is updated, the server updates user data at all clients and sends this message. Read more about user data in our guide: Understanding User Data.

Whenever a peer updates his data, all other peers receive the PeerUpdated event to handle the new data.

Event summary

Sending Arbitrary Data

You can use ODIN to send arbitrary data to other clients. You can use this method to build simple multiplayer games that don't require complex, real-time movement. For many casual games or board games, this message is enough to sync the players positions and other information of the game state with all clients.

The data you can send is basically just an array of bytes. You can use any data serialization that makes sense to you. Many game engines already provide data serialization features.

info

Note: You will only receive the MessageReceived event if your own peer ID was in the list of recipients.

Event Summary

Disconnecting

If peers disconnect other peers will be notified with the PeerLeft events.

Event Summary

Getting Kicked

If a peer is kicked from the server, this message flow will take place:

Event Summary

Next Steps

Unity

Use our deep Unity integration to add the most immersive in-game voice chat to your product with minimal development overhead.

Learn more
Unreal Engine

Our Unreal Engine plugin features full support for all available platforms and comes with Blueprint and C++ support.

Still not convinced or wanting to learn more? We have compiled a couple of use cases and how ODIN is best suited to handle them perfectly, being it a First Person Shooter or a MMO Battle Royal Game.

Next: Use Cases