Real-Time Indices
Lightning-fast cloud inference. Listen to the LFM's real-time outputs to adapt your native app instantly.
How Real-Time Inference Works
As the SDK quietly streams telemetry from the device, the LFM acts as a highly-optimized inference engine. It interprets how a person feels right this millisecond by rapidly analyzing roughly 50 constructed kinematic variables (e.g., tremor amplitude, stroke speed, tap cadence, pressure variance).
Because this layer runs on our specialized infrastructure rather than the user's device, it operates with sub-120ms latency while keeping your app's CPU and battery footprint completely untouched. It streams two primary indices back to your Swift code via WebSockets: the Game Behaviour Index (GBI) and the Brain Charge Index (BCI).
Game Behaviour Index (GBI)
The spectrum of engagement, mapping boredom to frustration.
Despite the name ("Game"), this index applies perfectly to all digital applications. The GBI measures mechanical arousal and valence. When a user is bored, their kinematic energy drops (slow, lazy, rhythmic sweeps). When frustrated, their kinematic energy spikes chaotically (hard taps, rapid backspacing, heavy pressure).
The Data Contract (Swift)
public enum GBIStateCategory: Int {
case severeBoredom = -2
case mildBoredom = -1
case flowState = 0
case mildFrustration = 1
case severeFrustration = 2
}
public struct GBIState {
// Ranges from -1.0 (Boredom) to +1.0 (Frustration). 0.0 is perfect Flow.
public let score: Float
// The categorized bucket for easy switch-statements
public let category: GBIStateCategory
// 0.0 to 1.0 indicating how confident the LFM is in this reading
public let confidence: Float
public let timestampUTC: Date
}Brain Charge Index (BCI)
The measure of cognitive load, attention, and mental fatigue.
Every intense interaction drains cognitive capacity. The BCI looks at the degradation of precision and reaction timing to estimate how much "Brain Charge" the user has left before their performance falls off a cliff or they abandon the session.
The Data Contract (Swift)
public enum TrendDirection: Int {
case decreasing = -1
case stable = 0
case increasing = 1 // Cognitive recovery
}
public enum BCILevel: Int {
case depleted = 0 // High risk of churn / mistakes
case fatigued = 1
case optimal = 2
case peak = 3 // Hyper-focused
}
public struct BCIState {
// Ranges from 0.0 (Depleted) to 1.0 (Peak Focus)
public let score: Float
public let level: BCILevel
public let trend: TrendDirection
// Milliseconds since the last significant shift in BCI
public let timeInStateMs: Int64
}Accessing the Data
Because the iOS SDK runs directly inside your host application's memory space, you can subscribe to these updates instantly using native closures, or route them via your backend depending on your architecture.
Route 1: In-App Observables (Client)
The most common approach is subscribing directly to the SDK's Swift observables. The SDK maintains a fast WebSocket connection to the LFM, pushing state changes directly to your UI threads.
import UIKit
import Nx10Core
class EmotionManager {
func startListening() {
// Listen for Frustration / Boredom shifts
Nx10Core.shared.insights.observeGBI { [weak self] gbiState in
guard let state = gbiState, state.confidence > 0.6 else { return }
if state.category == .severeFrustration {
self?.triggerHelpUI()
}
}
// Listen for Cognitive Fatigue shifts
Nx10Core.shared.insights.observeBCI { [weak self] bciState in
guard let state = bciState else { return }
if state.level == .depleted && state.trend == .decreasing {
self?.suggestTakingABreak()
}
}
}
private func triggerHelpUI() {
print("User is frustrated! Offering live chat support.")
}
}Route 2: Server-to-Server Webhooks
If your app requires authoritative backend intervention (e.g., blocking a financial transaction due to user distress), you can configure the Nx10 Control Plane to fire Webhooks to your backend whenever a user crosses a critical emotional threshold.
app.post('/api/nx10/webhooks', express.json(), (req, res) => {
const { deviceId, eventType, payload } = req.body;
if (eventType === 'gbi_critical_threshold') {
const gbi = payload.gbiState;
if (gbi.category === 'SevereFrustration') {
console.log(`[COMPLIANCE] User ${deviceId} is highly frustrated.`);
// Pause trading capabilities on the backend to prevent revenge-trading
tradingService.lockAccountTemporarily(deviceId, "Cool down period");
}
}
res.status(200).send('Received');
});