OddSockets Unity SDK
Official Unity SDK for OddSockets real-time messaging platform
Overview & Features
The OddSockets Unity SDK provides a powerful, Unity-optimized interface for real-time messaging in games and interactive applications.
Unity Optimized
Designed specifically for Unity's threading model with main thread marshaling and coroutine support.
Cross-Platform
Works on all Unity-supported platforms: PC, Mac, Linux, iOS, Android, WebGL, and consoles.
Coroutine Native
All async operations return Unity coroutines for seamless integration with Unity's async patterns.
High Performance
Optimized for low latency gaming with efficient WebSocket connections and smart routing.
Cost Effective
No per-message pricing, industry-standard 32KB message limits, transparent pricing.
Automatic Failover
Built-in redundancy and intelligent error handling for 99.9% uptime in production games.
Installation
Download and import the Unity package directly:
1. Download: https://github.com/oddsockets/unity-sdk/releases/latest/download/oddsockets-unity.unitypackage
2. In Unity: Assets → Import Package → Custom Package
3. Select the downloaded .unitypackage file
4. Import all files
Add via Unity Package Manager using Git URL:
1. Open Unity Package Manager (Window → Package Manager)
2. Click the + button → Add package from git URL
3. Enter: https://github.com/oddsockets/unity-sdk.git
4. Click Add
Manual installation by copying scripts:
git clone https://github.com/oddsockets/unity-sdk.git
# Copy Scripts/ folder to your Unity project's Assets/ directory
Quick Start
Basic Usage
using UnityEngine;
using OddSockets.Unity;
public class ChatManager : MonoBehaviour
{
private OddSocketsUnityClient client;
private OddSocketsUnityChannel chatChannel;
void Start()
{
// Initialize the client
var config = new OddSocketsUnityConfig
{
ApiKey = "ak_live_1234567890abcdef",
UserId = "player123",
AutoConnect = true
};
client = new OddSocketsUnityClient(config);
// Set up event handlers
client.OnConnected += OnConnected;
client.OnError += OnError;
// Connect to the platform
StartCoroutine(client.ConnectAsync());
}
private void OnConnected()
{
Debug.Log("Connected to OddSockets!");
// Get a channel and subscribe
chatChannel = client.Channel("game-chat");
StartCoroutine(chatChannel.SubscribeAsync(OnMessage));
}
private void OnMessage(OddSocketsMessage message)
{
Debug.Log($"Received: {message.Data}");
}
private void OnError(System.Exception error)
{
Debug.LogError($"OddSockets error: {error.Message}");
}
public void SendMessage(string text)
{
if (chatChannel != null)
{
StartCoroutine(chatChannel.PublishAsync(new { text = text, player = "Player1" }));
}
}
void OnDestroy()
{
client?.Dispose();
}
}