-
- 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 tokio runtime; 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 startSession calls.final List<SessionSummary>getSessions()GET /sessions— prior sessions for the configureduserId.final SessionHistorygetSession(String id)GET /session/<id>— history for one session.final StartSessionResponsestartSession(StartSessionOptions options)Open a session and return its StartSessionResponse (sessionId, url, token).final UnitjoinSession(JoinSessionInput input)Attach to a session whose StartSessionResponse was obtained out of band (multi-device handoff, deeplink, persisted session). final UnitendSession(String id)final UnitendAllSessions()final List<ActiveSession>activeSessions()Snapshot of every active session. 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 sessionId, String path, String fileName, String uploadId, Function1<UploadProgress, Unit> onProgress)Upload a file from the local filesystem to the named session and return the server-issued Attachment. final AttachmentuploadAttachment(String sessionId, 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(String sessionId, 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 sessionId, String attachmentId)Cancel an in-flight upload or delete a completed attachment on the named session. 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)
Replace session-level attributes injected as
data.attributeson subsequent startSession calls. Pass null to clear.
-
getSessions
final List<SessionSummary> getSessions()
GET /sessions— prior sessions for the configureduserId.
-
getSession
final SessionHistory getSession(String id)
GET /session/<id>— history for one session.
-
startSession
final StartSessionResponse startSession(StartSessionOptions options)
Open a session and return its StartSessionResponse
(sessionId, url, token).Returning does not mean the media plane is connected. For a Channel.VOICE session the MoQ dial runs in the background after this returns: 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. A Channel.CHAT session completes its (quick) SSE dial before returning and still throws on SSE-dial failure. Throws only for the/session/startHTTP failure, a chat SSE-dial failure, or a malformed request.
-
joinSession
final Unit joinSession(JoinSessionInput input)
Attach to a session whose StartSessionResponse was obtained out of band (multi-device handoff, deeplink, persisted session).
Like startSession, a Channel.VOICE session dials MoQ in the background — returning here does not mean it is connected; await the
Connected/Disconnectedevent. A Channel.CHAT session completes its SSE dial before returning.
-
endSession
final Unit endSession(String id)
-
endAllSessions
final Unit endAllSessions()
-
activeSessions
final List<ActiveSession> activeSessions()
Snapshot of every active session.
-
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 startSession 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 sessionId, String path, String fileName, String uploadId, Function1<UploadProgress, Unit> onProgress)
Upload a file from the local filesystem to the named session 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.
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(String sessionId, 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(String sessionId, 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 sessionId, String attachmentId)
Cancel an in-flight upload or delete a completed attachment on the named session.
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. A 404 from the server surfaces as SessionException with
kind = SessionBridge.ERROR_HTTPandstatusCode == 404— safe to treat as success when your intent was "remove the draft from the UI".
-
pollEvent
final ClientEvent pollEvent()
Polls the next event. Returns null when the queue is idle.
-
-
-
-