Data Communication Options in ODIN
Sometimes you want to send data other than audio data across ODIN clients in your game. While you can use Unreal's replication system, sometimes it makes more sense to distribute specific data via ODIN, either because they are voice chat related, need to be mapped to the corresponding ODIN client or because you want to integrate with a non-Unreal client that is only connected via ODIN (e.g. a web spectator or similar).
In this guide we want to discuss the different methods to distribute additional data across clients via ODIN Voice Chat Servers. This data can be anything from user names, positional data or messages. We will discuss the different applications of each way of communication, as well as their advantages and disadvantages. Lastly we show how to implement each of these methods so you can easily apply that to your project.
For detailed examples of each of these options and their applications, you can have a look at our advanced Unreal Tech Demo.
Choosing a Communication Method
Most importantly you should consider if the data you send describes a peer, represents a single event, or changes continuously. For each kind of data Odin provides an own way of sending. Choosing an appropriate one enables the receiving clients to properly handle the incoming data.
| Data | Method | Example | New Peers |
|---|---|---|---|
| Information about a peer that other clients should be able to read at all times | Peer User Data | User name, network ID, or self-mute state | new peers receive the latest state of the peer's user data when they join |
| A message or event that only needs to be delivered once it happens | RPCs | Chat messages | new peers will not receive RPC's sent before the join |
| Values that change frequently while a client is connected | Sockets | Position updates for a mini map | new peers will not receive socket messages sent before the join |
Use Peer User Data for properties associated with an ODIN peer. Other clients receive the data as soon as they learn about the peer's presence. This means, even if the user data is set, before another client joins the ODIN room, they get current state of the user data together with the On Peer Joined Room event.
Use RPCs for individual messages or actions, such as a chat message. Send them when the event occurs, and handle the incoming event in the receiving Blueprint. A message RPC can target specific peers or everyone in the room. Once sent, they are immediately forgotten. Still, you can send them reliably if you wish to make sure that the RPC will reach its target.
Use Sockets for a stream of updates, such as positions that change throughout a match. In this case, clients need the latest value as it arrives rather than a property attached to the peer or a separate action for every update.
You can combine these methods in one project. Our Unreal Tech Demo uses Peer User Data for player details, RPCs for chat messages, and Sockets for mini map positions - these could now even be used in a Web Client with the same map information. The following sections show how to set up each method with Blueprints.
RPCs
Use a message RPC when you want to send data once, such as a chat message or an interaction notification. The Send Message RPC node takes a request containing the message data and a list of recipient peer IDs. Leave the list empty to send the message to all peers in the room. Convert text to bytes before adding it to the request, and convert it back when you receive it.
PeerIDsempty to send to every one in the ODIN room.Bind to On Message Received on the room to handle incoming messages.

Its data includes the sender's peer ID and the message as a byte array. Use the peer ID when the sender matters to your game, for example to display a name beside a chat message, if not included in the message data:
Senderand Message fields. Then we apply these to a method on the UI that displays the chat message.Peer User Data
Peer User Data belongs to a specific ODIN peer. It is useful for details that other clients need when identifying that peer, such as a player name, team, or Unreal network ID. Add the initial user data to the authentication JSON before connecting to the room, so it is available when other clients receive the peer join event.
First, construct a new Json Object and set the desired fields, e.g. player name, or networking id. You can set the user data Json Object as an instance variable, so you can change single fields of it later without having to completely re-construct the Json:
SelfMuted state. Since you might turn off your microphone once and then stay silent, each new client would need to know the current state of each other peer. We can set the Muted field e.g. to its state from the last session.Then, set the user_data field on the Authentication Json that is returned by the Generate Room Token method of your join room routine and use the Authentication Json when connecting the room as usual:

This initial state will be received by all other clients once the JoinRoom is completed. Future clients will receive the current state of the User Data when they join the room. In this sample the Muted field is used in the Update Peer Self Muted
Muted field when another peer joins the room. The DEMO // Update Peer Self Muted Node updates all UI elements that reflect that property of the according ODIN peer.When a value changes, use Send ChangeSelf RPC to update the local peer's user data.
Muted field on the Peer User Data Json Object that we have created earlier. Now we can send it via SendChangedSelfRPC.Other clients can read the initial byte array from On Peer Joined and react to updates through On Peer Changed. Decode the data in both handlers using the same format that you used when sending it.

Muted field when another peer joins updates its user data. The DEMO // Update Peer Self Muted Node updates all UI elements that reflect that property of the according ODIN peer.Sockets
Sockets are useful for data that changes repeatedly, such as positions on a mini map.
Create a socket for the room and choose whether its data should be sent reliably or with lower latency and possible packet loss. A socket can address a specific peer or all peers in the room. Keep the socket for the duration of the room session, and create a new one after reconnecting.
Unrealiable socket to drop missed position updates instead of retrying since we would just use the most recent update. Then we create a looping timer that calls a function to send the current position via the socket, every fifth of a second.Then send the latest value through that socket as it changes or periodically.
OdinId and PosXand PosY to the X and Y positions of the locally controlled character. Then we encode this as bytes and send these via the Odin Socket created earlier.Handle incoming data through the socket message event and decode it using the same format as the sender. The Unreal Tech Demo's mini map positions provide an example of this update pattern.
OdinRoom instance, before connecting.
OdinId, PosX and PosY and use these to update the Mini Map.Raw RPC Commands
The Blueprint nodes above handle the usual data communication tasks. If you need direct access to ODIN's signaling protocol, use Send RPC to pass a JSON command to the server. The JSON must follow a command format that the server recognizes; sending an arbitrary JSON object will not turn it into a message for other peers.
For example, this ChangeSelf command updates the local peer's user data:
Connect the room to the Send RPC node and pass the serialized JSON string to its JSON input. Its Boolean return value tells you whether the request was sent, not whether the server accepted the command. Bind to On RPC if you need to inspect the raw JSON events returned by the server. For the examples in this guide, the dedicated Send ChangeSelf RPC and Send Message RPC nodes and their corresponding Blueprint events are easier to use.
Conclusion
This wraps this overview of the different ways of communicating additional data across your ODIN Voice Chat connection. For more details on the different nodes, check our Blueprint Reference. For a general guide, on how to connect to ODIN using Blueprints in Unreal, see our Getting Started Guide.