This document defines the stable public API surface for socketio-unity v1.0.0+.
These APIs are guaranteed stable for the v1.x lifecycle. Breaking changes will only occur in v2.0.0+.
Connection Management:
void Connect(string url)
void Disconnect()
void Shutdown()
void Dispose()Namespace Management:
NamespaceSocket Of(string ns, object auth = null)Event Handling (Default Namespace):
void On(string eventName, Action<string> handler)
void On(string eventName, Action<byte[]> handler)
void Off(string eventName, Action<string> handler)
void Off(string eventName, Action<byte[]> handler)Event Emission (Default Namespace):
void Emit(string eventName, object payload)
void Emit(string eventName, object payload, Action<string> ack, int timeoutMs = 5000)Properties & Events:
bool IsConnected { get; }
ConnectionState State { get; } // v1.2.0+
event Action OnConnected
event Action OnDisconnected
event Action<SocketError> OnError // v1.3.0+: typed error (was Action<string>)
event Action<ConnectionState> OnStateChanged // v1.3.0+Reconnect Configuration (v1.1.0+):
ReconnectConfig ReconnectConfig { get; set; }public enum ConnectionState
{
Disconnected,
Connecting,
Connected,
Reconnecting
}public readonly struct SocketError
{
public ErrorType Type { get; }
public string Message { get; }
}
public enum ErrorType { Transport, Auth, Timeout, Protocol }Event Handling:
void On(string eventName, Action<string> handler)
void On(string eventName, Action<byte[]> handler)
void Off(string eventName, Action<string> handler)
void Off(string eventName, Action<byte[]> handler)Event Emission:
void Emit(string eventName, object payload)
void Emit(string eventName, object payload, Action<string> ack, int timeoutMs = 5000)Events:
event Action OnConnected
event Action OnDisconnectedThread Safety:
static void Enqueue(Action action)
static bool IsInitialized { get; }OnError changed from Action<string> to Action<SocketError> to enable typed error handling.
// v1.2.x (old)
socket.OnError += (string msg) => Debug.LogError(msg);
// v1.3.0+ (new)
socket.OnError += (SocketError err) => Debug.LogError($"[{err.Type}] {err.Message}");This is the only breaking change in the v1.x lifecycle. All other stable APIs remain intact.
These APIs are subject to change in minor releases (v1.x → v1.y).
// Direct field mutation on a retrieved config is supported in v1.x
// but the getter may return a copy in v2.0
socket.ReconnectConfig.maxDelay = 60f; // Works in v1.x, avoid in new codeRecommended pattern (forward-compatible):
var cfg = new ReconnectConfig { maxDelay = 60f };
socket.ReconnectConfig = cfg;SocketIOTrace.*TraceConfig.*SocketIOProfilerCounters.*SocketIOThroughputTracker.*
Why: These are editor/debugging tools, not core client functionality.
On SocketIOClient:
int NamespaceCount { get; }
int PendingAckCount { get; }
float PingRttMs { get; }On NamespaceSocket:
int PendingAckCount { get; }Why: These are primarily for the Editor HUD. May be moved to a separate debugging API.
void Tick() // On SocketIOClient and NamespaceSocketWhy: Part of ITickable interface for Unity tick integration. Public due to interface, but do not call directly.
These are internal or in non-public namespaces. Do not rely on these.
EngineIOClientSocketPacketParserBinaryPacketAssemblerReconnectControllerNamespaceManager- Transport interfaces (
ITransport,WebSocketTransport, etc.)
If we must break a stable API in v2.0.0, we will:
- Mark the old API
[Obsolete]in the last v1.x release - Provide a clear migration path in the changelog
- Keep the old API working for at least one major version
✅ Safe to use in production:
SocketIOClientcore methodsNamespaceSocketmethodsUnityMainThreadDispatcher.Enqueue()
- Debugging/profiler APIs (may change structure)
- Internal classes (may be refactored)
❌ Avoid:
- Directly instantiating transports
- Accessing internal protocol classes