-
- 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)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 BooleantoggleHold(String id)Returns the new hold state. final UnitsendDtmf(String id, Character digit, Integer durationMs)digitmust be one of0-9,*,#,A-Dper RFC 4733.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, Context context, Uri uri, String fileName, String uploadId, Function1<UploadProgress, Unit> onProgress)Convenience overload that copies a content:// (or file:///android.resource://) uri intocontext.cacheDirbefore uploading, then deletes the cache file once the upload settles.final AttachmentuploadAttachment(String sessionId, Context context, ByteArray bytes, String fileName, String uploadId, Function1<UploadProgress, Unit> onProgress)Convenience overload for in-memory bytes: writes them to context.cacheDirfirst, 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)
-
joinSession
final Unit joinSession(JoinSessionInput input)
Attach to a session whose StartSessionResponse was obtained out of band (multi-device handoff, deeplink, persisted session).
-
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)
-
toggleHold
final Boolean toggleHold(String id)
Returns the new hold state.
-
sendDtmf
final Unit sendDtmf(String id, Character digit, Integer durationMs)
digitmust be one of0-9,*,#,A-Dper RFC 4733.
-
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, Context context, Uri uri, String fileName, String uploadId, Function1<UploadProgress, Unit> onProgress)
Convenience overload that copies a content:// (or
file:///android.resource://) uri intocontext.cacheDirbefore uploading, then deletes the cache file once the upload settles. The SDK can't opencontent://URIs directly.
-
uploadAttachment
final Attachment uploadAttachment(String sessionId, Context context, ByteArray bytes, String fileName, String uploadId, Function1<UploadProgress, Unit> onProgress)
Convenience overload for in-memory bytes: writes them to
context.cacheDirfirst, 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.
-
-
-
-