-
- All Implemented Interfaces:
-
java.lang.AutoCloseable
public final class OrigonClient implements AutoCloseable
The primary interface to the Origon platform on Android.
Backed by
libsession.sovia SessionBridge. One instance owns one native handle and one smol executor; create at app start, call close (or useuse { }) at app shutdown.All fallible methods throw SessionException with a structured
kind/statusCode/code/message.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classOrigonClient.Companion
-
Field Summary
Fields Modifier and Type Field Description private final StringstartMessageprivate final BooleanisChatEnabledprivate final BooleanisCallEnabledprivate final BooleanmultipleChannelsprivate final AttachmentPolicyattachmentPolicyprivate final ServerConfigserverConfig
-
Constructor Summary
Constructors Constructor Description OrigonClient(Context context, ClientConfig config)
-
Method Summary
Modifier and Type Method Description final StringgetStartMessage()final BooleangetIsChatEnabled()final BooleangetIsCallEnabled()final BooleangetMultipleChannels()final AttachmentPolicygetAttachmentPolicy()final ServerConfiggetServerConfig()Unitclose()final UnitsetAttributes(JsonObject attributes)Replace session-level attributes injected as data.attributeson subsequent startCall / startChat calls.final Flow<SessionLoadUpdate>sessionUpdates(String id, SessionLoadPolicy policy)Finite cache/network transcript load. final Flow<SessionsLoadUpdate>sessionDirectoryUpdates(SessionLoadPolicy policy)Finite cache/network directory load. final SessionSnapshotcachedSession(String id)final SessionSnapshotrefreshSession(String id)final SessionsSnapshotcachedSessions()final SessionsSnapshotrefreshSessions()final <ERROR CLASS>removeCachedSession(String id)final <ERROR CLASS>clearChatCache()final <ERROR CLASS>pruneChatCache()final StartSessionResponsestartCall(StartCallOptions options)Start a voice call. final StartSessionResponsestartChat(StartChatOptions options)Start a chat, sending the visitor's first message as part of the call. final List<RestoreResult>restoreActiveChats()Passively attach retained active chats without replacing another install. final StartSessionResponseopenChat(String sessionId, ChatAccessIntent intent)Attach using named authority; notification and navigation are explicit takeover intents. final UnitjoinCall(JoinInput input)Attach to a voice call whose StartSessionResponse was obtained out of band (multi-device handoff, deeplink, persisted session). final UnitjoinChat(JoinInput input)Attach to an existing chat obtained out of band — the agent / chat-offered path. final UnitendSession(String id)final UnitendAllSessions()final UnitunregisterForPushNotifications()Generation-bound logout gate. final List<ActiveSession>activeSessions()Snapshot of every active session. final UnitsendDtmf(String id, Character digit)Send one DTMF symbol to the active voice session's CX flow. final UnitsetMute(String id, Boolean muted)final UnitsetMuteAll(Boolean muted)final UnitsetAudioOutput(AudioOutputRoute route)Override the audio output route (speaker / receiver / Bluetooth). final MessagesendMessage(String id, SendMessagePayload payload)Chat-only — send a text / HTML message on the named session. final UnitnotifyTyping(String id)Chat-only — register a keystroke on the named session. final UnitstopTyping(String id)Chat-only — force outbound typing state to "off" immediately, cancelling any in-flight debounce. final AttachmentuploadAttachment(String path, String fileName, String uploadId, Function1<UploadProgress, Unit> onProgress)Upload a file from the local filesystem against the widget this client was created for, and return the server-issued Attachment. final AttachmentuploadAttachment(Uri uri, String fileName, String uploadId, Function1<UploadProgress, Unit> onProgress)Convenience overload that copies a content:// (or file:///android.resource://) uri into the app's cache dir before uploading, then deletes the cache file once the upload settles.final AttachmentuploadAttachment(ByteArray bytes, String fileName, String uploadId, Function1<UploadProgress, Unit> onProgress)Convenience overload for in-memory bytes: writes them to the app's cache dir first, then delegates to the path-based overload. final UnitdeleteAttachment(String attachmentId)Cancel an in-flight upload or delete a completed attachment. final ClientEventpollEvent()Polls the next event. -
-
Constructor Detail
-
OrigonClient
OrigonClient(Context context, ClientConfig config)
-
-
Method Detail
-
getStartMessage
final String getStartMessage()
-
getIsChatEnabled
final Boolean getIsChatEnabled()
-
getIsCallEnabled
final Boolean getIsCallEnabled()
-
getMultipleChannels
final Boolean getMultipleChannels()
-
getAttachmentPolicy
final AttachmentPolicy getAttachmentPolicy()
-
getServerConfig
final ServerConfig getServerConfig()
-
setAttributes
final Unit setAttributes(JsonObject attributes)
-
sessionUpdates
final Flow<SessionLoadUpdate> sessionUpdates(String id, SessionLoadPolicy policy)
Finite cache/network transcript load. At most cache then network is emitted.
-
sessionDirectoryUpdates
final Flow<SessionsLoadUpdate> sessionDirectoryUpdates(SessionLoadPolicy policy)
Finite cache/network directory load. At most cache then network is emitted.
-
cachedSession
final SessionSnapshot cachedSession(String id)
-
refreshSession
final SessionSnapshot refreshSession(String id)
-
cachedSessions
final SessionsSnapshot cachedSessions()
-
refreshSessions
final SessionsSnapshot refreshSessions()
-
removeCachedSession
final <ERROR CLASS> removeCachedSession(String id)
-
clearChatCache
final <ERROR CLASS> clearChatCache()
-
pruneChatCache
final <ERROR CLASS> pruneChatCache()
-
startCall
final StartSessionResponse startCall(StartCallOptions options)
Start a voice call. Posts
/session/startand brings the media plane up.Returning does not mean the media plane is connected. The MoQ dial runs in the background: connect success arrives as a
ClientEvent.Connectedand a dial failure as aClientEvent.Disconnected(TransportClosed) on the event stream — not as a thrown SessionException. Calling endSession with the returned id while still dialing cancels the in-flight dial. Throws only for the/session/startHTTP failure or a malformed request.
-
startChat
final StartSessionResponse startChat(StartChatOptions options)
Start a chat, sending the visitor's first message as part of the call.
The first message is required — see StartChatOptions for why. The session id comes back BEFORE the message is sent, so the provisional
MessageAddedevent always has a session to belong to.A first message that fails to DELIVER does not throw: the session is live and the failure arrives as
MessageUpdatedwithstatus = FAILED, so the user can retry. Only a TERMINAL refusal (the session is already gone) throws — returning normally would leave the app rendering a composer on a dead conversation.
-
restoreActiveChats
final List<RestoreResult> restoreActiveChats()
Passively attach retained active chats without replacing another install.
-
openChat
final StartSessionResponse openChat(String sessionId, ChatAccessIntent intent)
Attach using named authority; notification and navigation are explicit takeover intents.
-
joinCall
final Unit joinCall(JoinInput input)
Attach to a voice call whose StartSessionResponse was obtained out of band (multi-device handoff, deeplink, persisted session).
Like startCall, the MoQ dial runs in the background — returning here does not mean it is connected; await the
Connected/Disconnectedevent.
-
joinChat
final Unit joinChat(JoinInput input)
Attach to an existing chat obtained out of band — the agent / chat-offered path. Completes the attach before returning.
Takes no first message, unlike startChat: joining is entering a room whose first-message gate is ALREADY released — the visitor has spoken, which is why this participant is being offered the conversation — so there is no deadline left to race.
-
endSession
final Unit endSession(String id)
-
endAllSessions
final Unit endAllSessions()
-
unregisterForPushNotifications
final Unit unregisterForPushNotifications()
Generation-bound logout gate. Completes before returning so close is safe next.
-
activeSessions
final List<ActiveSession> activeSessions()
Snapshot of every active session.
-
sendDtmf
final Unit sendDtmf(String id, Character digit)
Send one DTMF symbol to the active voice session's CX flow.
digit must be one uppercase ASCII symbol from
0-9,*,#, orA-D. The SDK sends control data only; it does not synthesize audio, tones, clicks, or haptics.
-
setMuteAll
final Unit setMuteAll(Boolean muted)
-
setAudioOutput
final Unit setAudioOutput(AudioOutputRoute route)
Override the audio output route (speaker / receiver / Bluetooth).
Process-global — affects the app's single active voice session, so it takes no session id. A no-op when no call is active. UI typically wraps this as a boolean speaker toggle (AudioOutputRoute.SPEAKER / AudioOutputRoute.AUTOMATIC).
May block while the audio output stream is reopened; call it off the main thread.
-
sendMessage
final Message sendMessage(String id, SendMessagePayload payload)
Chat-only — send a text / HTML message on the named session.
Requires an active chat session for id (call startChat first). The SDK fires ClientEvent.MessageAdded (provisional,
status == SENDING) before the wire round-trip and ClientEvent.MessageUpdated (delivered or failed) after — both surface on pollEvent. Returns the server-issued Message.
-
notifyTyping
final Unit notifyTyping(String id)
Chat-only — register a keystroke on the named session. Cheap to call from a
TextWatcher; the SDK debounces outbound<sessionUrl>/typingPOSTs so only one wire call fires per typing burst.
-
stopTyping
final Unit stopTyping(String id)
Chat-only — force outbound typing state to "off" immediately, cancelling any in-flight debounce. UI fires this on empty-text transitions; the SDK also fires it implicitly on sendMessage and on endSession.
-
uploadAttachment
final Attachment uploadAttachment(String path, String fileName, String uploadId, Function1<UploadProgress, Unit> onProgress)
Upload a file from the local filesystem against the widget this client was created for, and return the server-issued Attachment. The SDK streams the body straight from disk; auto-detects MIME from a 256-byte head plus the fileName extension. Runs on Dispatchers.IO.
There is no
sessionIdand no session prerequisite — an attachment can be the first thing a visitor sends.uploadId doubles as the cancellation key — pass it as
attachmentIdto deleteAttachment while the upload is in flight to abort it (throws withkind = ERROR_CANCELLED). After completion, use the server-issuedattachment.idfor deletion.onProgress fires from a JNI worker thread; hop to the main thread before touching UI state.
percentisnullwhen the total size is unknown.Throws SessionException:
ERROR_OTHERfor filesystem errors,ERROR_ATTACHMENTfor precheck failures (empty_file,policy_unsupported_type,policy_type_disabled,policy_too_large),ERROR_HTTP/ERROR_SERVER_UNAVAILABLEfor wire failures,ERROR_CANCELLEDwhen cancelled.
-
uploadAttachment
final Attachment uploadAttachment(Uri uri, String fileName, String uploadId, Function1<UploadProgress, Unit> onProgress)
Convenience overload that copies a content:// (or
file:///android.resource://) uri into the app's cache dir before uploading, then deletes the cache file once the upload settles. The SDK can't opencontent://URIs directly.
-
uploadAttachment
final Attachment uploadAttachment(ByteArray bytes, String fileName, String uploadId, Function1<UploadProgress, Unit> onProgress)
Convenience overload for in-memory bytes: writes them to the app's cache dir first, then delegates to the path-based overload.
-
deleteAttachment
final Unit deleteAttachment(String attachmentId)
Cancel an in-flight upload or delete a completed attachment. Session-less like uploadAttachment.
attachmentIdis dual-purpose: it can be either theuploadIdpassed to uploadAttachment (cancels the in-flight upload — no network call, the upload's awaiter throws SessionException withkind = SessionBridge.ERROR_CANCELLED) or the server-issuedattachment.idof a completed upload (issuesDELETEon the server). The SDK figures it out: it checks its in-flight uploads table first, then falls through to the wire call.Runs on Dispatchers.IO. The server is idempotent on a missing object and answers 204, so a successful return does not prove the id existed; a 404 means the route did not match. An id that could not form a usable path is refused by the SDK before any request.
-
pollEvent
final ClientEvent pollEvent()
Polls the next event. Returns null when the queue is idle.
-
-
-
-