-
public final class ZeroGpuWebSocketA single device WebSocket session. Instances are single-use: connect once, disconnect once. The owning ai.zerogpu.android.sdk.ZeroGpuSdk creates a fresh instance per (re)connection and drives the foreground/background lifecycle; this class only opens the socket, does the hello handshake, relays tasks, and reports terminal closure via onClosed. The OkHttpClient is shared and owned by the node (so reconnects don't leak thread/connection pools).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classZeroGpuWebSocket.Companion
-
Field Summary
Fields Modifier and Type Field Description private Function1<TaskMessage, Unit>onTaskprivate Function0<Unit>onReadyprivate Function1<Boolean, Unit>onClosedprivate Function1<ConnectionPolicy, Unit>onPolicyUpdateprivate Function1<Long, Unit>onReregisterprivate Function0<Unit>onPingTickprivate volatile BooleanisReady
-
Constructor Summary
Constructors Constructor Description ZeroGpuWebSocket(OkHttpClient client, String wsUrl, String deviceId, String sessionKey, List<SlmConfigStatus> slmConfigs, ErrorReporter errorReporter, EventReporter reporter, CoroutineScope scope, Function0<Long> pingIntervalSeconds)
-
Method Summary
Modifier and Type Method Description final Function1<TaskMessage, Unit>getOnTask()Invoked with each inbound task batch. final UnitsetOnTask(Function1<TaskMessage, Unit> onTask)Invoked with each inbound task batch. final Function0<Unit>getOnReady()final UnitsetOnReady(Function0<Unit> onReady)final Function1<Boolean, Unit>getOnClosed()Fired exactly once when the socket terminates. final UnitsetOnClosed(Function1<Boolean, Unit> onClosed)Fired exactly once when the socket terminates. final Function1<ConnectionPolicy, Unit>getOnPolicyUpdate()Invoked with the clamped-parsed policy from a policy_updatemessage.final UnitsetOnPolicyUpdate(Function1<ConnectionPolicy, Unit> onPolicyUpdate)Invoked with the clamped-parsed policy from a policy_updatemessage.final Function1<Long, Unit>getOnReregister()Invoked with the server's delay_jitter_mswhen areregisterdirective arrives.final UnitsetOnReregister(Function1<Long, Unit> onReregister)Invoked with the server's delay_jitter_mswhen areregisterdirective arrives.final Function0<Unit>getOnPingTick()Invoked after each app-level ping is sent (staleness safety-net hook). final UnitsetOnPingTick(Function0<Unit> onPingTick)Invoked after each app-level ping is sent (staleness safety-net hook). final BooleangetIsReady()final UnitsetIsReady(Boolean isReady)final Unitconnect()final Unitdisconnect(Integer code, String reason)final UnitsendStatus(String status)Client→server status update on the live session. final UnitsendTaskResults(List<TaskResult> results)-
-
Constructor Detail
-
ZeroGpuWebSocket
ZeroGpuWebSocket(OkHttpClient client, String wsUrl, String deviceId, String sessionKey, List<SlmConfigStatus> slmConfigs, ErrorReporter errorReporter, EventReporter reporter, CoroutineScope scope, Function0<Long> pingIntervalSeconds)
-
-
Method Detail
-
getOnTask
final Function1<TaskMessage, Unit> getOnTask()
Invoked with each inbound task batch. The host hops to a coroutine scope to run + reply.
-
setOnTask
final Unit setOnTask(Function1<TaskMessage, Unit> onTask)
Invoked with each inbound task batch. The host hops to a coroutine scope to run + reply.
-
getOnReady
final Function0<Unit> getOnReady()
-
setOnReady
final Unit setOnReady(Function0<Unit> onReady)
-
getOnClosed
final Function1<Boolean, Unit> getOnClosed()
Fired exactly once when the socket terminates. deliberate is true when disconnect closed it.
-
setOnClosed
final Unit setOnClosed(Function1<Boolean, Unit> onClosed)
Fired exactly once when the socket terminates. deliberate is true when disconnect closed it.
-
getOnPolicyUpdate
final Function1<ConnectionPolicy, Unit> getOnPolicyUpdate()
Invoked with the clamped-parsed policy from a
policy_updatemessage.
-
setOnPolicyUpdate
final Unit setOnPolicyUpdate(Function1<ConnectionPolicy, Unit> onPolicyUpdate)
Invoked with the clamped-parsed policy from a
policy_updatemessage.
-
getOnReregister
final Function1<Long, Unit> getOnReregister()
Invoked with the server's
delay_jitter_mswhen areregisterdirective arrives.
-
setOnReregister
final Unit setOnReregister(Function1<Long, Unit> onReregister)
Invoked with the server's
delay_jitter_mswhen areregisterdirective arrives.
-
getOnPingTick
final Function0<Unit> getOnPingTick()
Invoked after each app-level ping is sent (staleness safety-net hook).
-
setOnPingTick
final Unit setOnPingTick(Function0<Unit> onPingTick)
Invoked after each app-level ping is sent (staleness safety-net hook).
-
getIsReady
final Boolean getIsReady()
-
setIsReady
final Unit setIsReady(Boolean isReady)
-
disconnect
final Unit disconnect(Integer code, String reason)
-
sendStatus
final Unit sendStatus(String status)
Client→server status update on the live session. The registry's DeviceSession accepts a hello_ack-shaped message from an authenticated socket and flips the device
idle/error— this is the degrade/recover wire contract (no new message type).
-
sendTaskResults
final Unit sendTaskResults(List<TaskResult> results)
-
-
-
-