In-Session Communication
This page covers all APIs for communicating inside an EnableX Android video session: text chat (including edit and delete), custom data signalling, file sharing, screen sharing, canvas streaming, annotation, and live transcription.
Chat
EnableX supports public (broadcast), private (one-to-one), and group chat messaging. Messaging does not require the sender to have a published stream or the receiver to have a subscribed stream.
Send a Chat Message
EnxRoom.sendMessage() sends a text message to one or more participants in the session.
- Class:
EnxRoom
- Method:
public void sendMessage(String message, boolean isBroadcast, List<String> recipientIDs)
| Parameter | Type | Description |
message | String | The text message to send. |
isBroadcast | Boolean | true to send to all participants (public); false to send to specific recipients (private/group). |
recipientIDs | Array | List of client IDs to receive the message. Applicable only when isBroadcast is false. |
| Callback | Delivered To | Description |
onACKSendMessage | Sender | Acknowledgment that the message was sent, including a unique messageId. |
onMessageReceived | Recipients | Delivers the received message as a JSONObject. |
// Public broadcast — send to all
room.sendMessage("Hello everyone!", true, null);
// Private or group — send to specific recipients
List<String> recipientClientIds = new ArrayList<>();
recipientClientIds.add("clientId1");
room.sendMessage("Hello!", false, recipientClientIds);
// Sender receives acknowledgment
@Override
public void onACKSendMessage(JSONObject jsonObject) {
// Contains message details including messageId
}
// Recipients receive the message
@Override
public void onMessageReceived(JSONObject jsonObject) {
String textMessage = jsonObject.getString("msg");
}
Edit a Chat Message
EnxRoom.transactMessage() edits a previously sent chat message. The messageId is received via onACKSendMessage or onMessageReceived when the original message was sent.
- Class:
EnxRoom
- Method:
public void transactMessage(JSONObject option)
| Parameter | Type | Description |
message | String | The updated (edited) message text. |
messageId | String | Unique ID of the original message to be edited. |
type | String | Use "chat-update" to edit a message. |
| Callback | Delivered To | Description |
onACKUpdateMessage | Sender | Acknowledgment that the edit request was received. |
onMessageUpdate | Recipients | Delivers the updated message to all recipients. |
JSONObject option = new JSONObject();
option.put("message", "This is my edited message");
option.put("messageId", "3889493030");
option.put("type", "chat-update");
room.transactMessage(option);
// Sender receives acknowledgment
@Override
public void onACKUpdateMessage(JSONObject data) {
// Acknowledgment of the edit request
}
// Recipients receive the updated message
@Override
public void onMessageUpdate(JSONObject data) {
// data contains the updated message
}
Delete a Chat Message
EnxRoom.transactMessage() also handles message deletion. Use "chat-delete" as the type and provide the messageId of the message to remove.
- Class:
EnxRoom
- Method:
public void transactMessage(JSONObject option)
| Parameter | Type | Description |
messageId | String | Unique ID of the message to be deleted. |
type | String | Use "chat-delete" to delete a message. |
| Callback | Delivered To | Description |
onACKDeleteMessage | Sender | Acknowledgment that the delete request was received. |
onMessageDelete | Recipients | Notifies recipients that a message has been deleted. |
JSONObject option = new JSONObject();
option.put("messageId", "3889493030");
option.put("type", "chat-delete");
room.transactMessage(option);
// Sender receives acknowledgment
@Override
public void onACKDeleteMessage(JSONObject data) {
// Acknowledgment that the deletion was processed
}
// Recipients are notified of the deletion
@Override
public void onMessageDelete(JSONObject data) {
// data contains deleted message information
}
Custom Signalling
EnxRoom.sendUserData() sends a structured JSON payload to one or more participants without any EnableX message structure constraints. Use this to exchange application-specific instructions, polls, or any custom data during a session.
- Class:
EnxRoom
- Method:
public void sendUserData(JSONObject data, boolean isBroadcast, List<String> recipientIDs)
| Parameter | Type | Description |
data | JSON Object | A JSON object with custom keys. Passed to recipients without structure enforcement. |
isBroadcast | Boolean | true to broadcast to all participants; false to signal specific recipients. |
recipientIDs | Array | List of client IDs of intended recipients. Not used when isBroadcast is true. |
| Callback | Description |
onUserDataReceived | Delivers the received custom data as a JSONObject to the intended recipients. Available from Android SDK v1.5.3 and later. |
// Build your custom payload
JSONObject data = new JSONObject();
data.put("sender", "Alice");
data.put("message", "Custom instruction");
data.put("custom_key", "value");
// Broadcast to all participants
room.sendUserData(data, true, null);
// Send to specific recipients
List<String> recipientClientIds = new ArrayList<>();
recipientClientIds.add("clientId1");
room.sendUserData(data, false, recipientClientIds);
// Recipients receive the signal
@Override
public void onUserDataReceived(JSONObject jsonObject) {
// Handle the custom JSON payload
}
| Error Code | Description |
| 5127 | Exceeding the maximum allowed data transfer rate of 100 Kbps. |
File Sharing
File sharing allows participants to upload and download files within an RTC session. Available from Android SDK v1.5.3 and later. You must call setFileShareObserver(this) before using any file sharing API.
Required: Call room.setFileShareObserver(this) after connecting to the room before calling any file sharing methods.
Upload a File
EnxRoom.sendFiles() initiates a file transfer to the EnableX server. A UI is presented to the user to select the file to upload.
- Class:
EnxRoom
- Observer:
public void setFileShareObserver(EnxFileShareObserver object)
- Method:
public void sendFiles(FrameLayout view, boolean isBroadcast, List<String> clientIdList)
| Parameter | Type | Description |
view | FrameLayout | The layout where the file-picker UI is displayed. |
isBroadcast | Boolean | true to share with all participants; false to share with specific users. |
clientIdList | Array | List of client IDs of intended recipients. Not used when isBroadcast is true. |
| Callback | Delivered To | Description |
onInitFileUpload | Sender | Notified when the file upload process is initiated. |
onFileUploaded | Sender | Notified when the file has been uploaded successfully. |
onFileUploadFailed | Sender | Notified when the file upload fails. |
onFileUploadStarted | Receivers | Notified when a file upload begins (file is being uploaded). |
onFileAvailable | Receivers | Notified when a file is ready to download. |
room.setFileShareObserver(this);
// Broadcast the file to all participants
room.sendFiles(frameLayoutView, true, null);
// Callbacks at sender
@Override
public void onInitFileUpload(JSONObject jsonObject) {
// File upload has started
}
@Override
public void onFileUploaded(JSONObject jsonObject) {
// File uploaded successfully
}
@Override
public void onFileUploadFailed(JSONObject jsonObject) {
// File upload failed — handle error
}
// Callbacks at receivers
@Override
public void onFileUploadStarted(JSONObject jsonObject) {
// A file is being uploaded by another participant
}
@Override
public void onFileAvailable(JSONObject jsonObject) {
// A file is now available for download
}
Get Available Files
EnxRoom.getAvailableFiles() returns all files currently available for download in the session. Call this after joining the room to retrieve any files shared before you connected.
- Class:
EnxRoom
- Method:
public JSONArray getAvailableFiles()
JSONArray myFiles = room.getAvailableFiles();
// Returns an array of file info objects, e.g.:
// [ { "name": "report.pdf", "size": 191002, "index": 0 } ]
Download a Shared File
EnxRoom.downloadFile() downloads a file identified by its file info object (received via onFileAvailable or getAvailableFiles()).
- Class:
EnxRoom
- Method:
public void downloadFile(JSONObject fileInfo, boolean isAutoSave)
| Parameter | Type | Description |
fileInfo | JSON Object | File information object obtained from onFileAvailable or getAvailableFiles(). |
isAutoSave | Boolean | true to save the file automatically (callback includes the saved file path); false to receive Base64-encoded raw data to handle saving manually. |
| Callback | Description |
onInitFileDownload | Notified when the file download process is initiated. |
onFileDownloaded | Notified when the file has been downloaded (with or without auto-save). |
onFileDownloadFailed | Notified when the file download fails. |
room.downloadFile(fileInfoJsonObject, true);
@Override
public void onFileDownloaded(JSONObject jsonObject) {
// File downloaded — jsonObject contains path or Base64 data
}
@Override
public void onFileDownloadFailed(JSONObject jsonObject) {
// Download failed — handle error
}
Cancel a File Upload
Use cancelUpload() to cancel a specific ongoing upload, or cancelAllUploads() to cancel all uploads you initiated.
// Cancel a specific upload job
enxRoom.cancelUpload(jobId);
// Cancel all ongoing uploads
enxRoom.cancelAllUploads();
// Acknowledgment callback
@Override
public void onFileUploadCancelled(JSONObject jsonObject) {
// Upload has been cancelled
}
| Error Code | Description |
| 5089 | Storage access is denied. |
| 5090 | Failed to save the file. |
| 5091 | File sharing is not available in this context. |
| 5092 | Too many files to upload — maximum one file per request. |
| 5098 | Unable to cancel upload after upload is complete. |
| 5099 | Failed to cancel — invalid upload ID. |
| 5100 | Failed to upload a possibly corrupt file. |
| 1182 | Failed to upload file. |
| 1185 | File size exceeds the maximum allowed size. |
Cancel a File Download
Use cancelDownload() to cancel a specific ongoing download, or cancelAllDownloads() to cancel all downloads at your endpoint.
// Cancel a specific download job
enxRoom.cancelDownload(jobId);
// Cancel all ongoing downloads
enxRoom.cancelAllDownloads();
// Acknowledgment callback
@Override
public void onFileDownloadCancelled(JSONObject jsonObject) {
// Download has been cancelled
}
| Error Code | Description |
| 5089 | Storage access is denied. |
| 5090 | Failed to save the file. |
| 5101 | The file is already downloaded. |
| 1181 | File download is not available. Non-contextual method call. |
| 1183 | Failed to download the file. |
Screen Sharing
Screen sharing publishes the device screen as a video stream (Stream ID 101) at 6 fps. To receive shared screens, subscribe to Stream ID 101. Screen sharing must be enabled when creating the room: { "screen_share": true }.
You must call room.setScreenShareObserver(this) before calling any screen sharing method.
Android 11+ Note: On Android 11 (API level 30) or later, you must create a foreground service with mediaProjection foreground service type declared in your manifest before starting screen sharing. Screen sharing continues even when the application is in the background.
Start Screen Sharing
EnxRoom.startScreenShare() creates and publishes a screen share stream into the room.
- Class:
EnxRoom
- Observer:
public void setScreenShareObserver(EnxScreenShareObserver object)
- Method:
public void startScreenShare()
| Callback | Delivered To | Description |
onScreenSharedStarted | Everyone in room | Notifies all participants that screen sharing has started, providing the screen share stream object. |
// Register the observer before starting
room.setScreenShareObserver(this);
// Start screen sharing
room.startScreenShare();
// Received by everyone — screen share stream available (Stream ID 101)
@Override
public void onScreenSharedStarted(EnxStream enxStream) {
// enxStream is the screen share stream (ID 101)
// Attach to a player view and add to your layout
yourView.addView(enxStream.mEnxPlayerView);
}
Stop Screen Sharing
EnxRoom.stopScreenShare() stops the active screen sharing session initiated by the local user.
- Class:
EnxRoom
- Method:
public void stopScreenShare()
| Callback | Delivered To | Description |
onScreenSharedStopped | Everyone in room | Notifies all participants that screen sharing has stopped. |
room.stopScreenShare();
@Override
public void onScreenSharedStopped(EnxStream enxStream) {
// Remove the screen share view from layout
yourView.removeAllViews();
}
| Error Code | Description |
| 5107 | Repeated startScreenShare() call while a previous request is in process. |
| 1170 | Screen sharing is not supported in your subscription. |
Force Stop Sharing (Moderator Only)
EnxRoom.stopAllSharing() allows a moderator to force stop any ongoing screen sharing or canvas streaming by any participant in the room. This method is restricted to moderators and is not available to regular participants.
Moderator only: stopAllSharing() can only be called by a moderator. It stops both screen sharing and canvas streaming. Available from Android SDK v2.1.2 and later.
- Class:
EnxRoom
- Method:
public void stopAllSharing()
| Callback | Delivered To | Description |
onStopAllSharingACK | Everyone in room | Notifies all participants that all sharing has been stopped by the moderator. |
// Moderator force-stops all screen sharing and canvas streaming
EnxRoom.stopAllSharing();
@Override
public void onStopAllSharingACK(JSONObject jsonObject) {
// All sharing has been stopped — update your UI accordingly
}
Canvas Streaming
Canvas streaming publishes any Android View as a video stream (Stream ID 102) into the room. Canvas streaming must be enabled when creating the room: { "canvas": true }. To receive a canvas stream, subscribe to Stream ID 102.
Start Canvas Streaming
EnxRoom.startCanvas() starts publishing the specified view as a canvas stream into the room.
- Class:
EnxRoom
- Method:
public void startCanvas(View view)
- Parameter:
view — the Android View to publish as the canvas stream.
| Callback | Delivered To | Description |
onStartCanvasAck | Publisher | Acknowledgment to the publisher when canvas streaming starts. |
onCanvasStarted | Everyone in room | Notifies all participants that canvas streaming has started, providing the canvas stream object. |
room.startCanvas(yourView);
// Publisher receives acknowledgment
@Override
public void onStartCanvasAck(JSONObject jsonObject) {
// Canvas streaming started successfully
}
// Received by all participants — canvas stream available (Stream ID 102)
@Override
public void onCanvasStarted(EnxStream enxStream) {
// enxStream is the canvas stream (ID 102)
// Attach to a player view and display
EnxPlayerView canvasPlayerView = new EnxPlayerView(
CurrentClassContext, ScalingType, mediaOverlay);
enxStream.attachRenderer(canvasPlayerView);
yourView.addView(canvasPlayerView);
}
| Error Code | Description |
| 5103 | Canvas streaming or screen sharing is already active in the room. |
| 5105 | Repeated startCanvas() call when canvas stream is already active. |
| 5107 | Repeated startCanvas() call while a previous request is being processed. |
| 5110 | Failed to publish the canvas stream. |
Stop Canvas Streaming
EnxRoom.stopCanvas() stops the active canvas streaming session.
- Class:
EnxRoom
- Method:
public void stopCanvas()
| Callback | Delivered To | Description |
onStoppedCanvasAck | Publisher | Acknowledgment to the publisher when canvas streaming stops. |
onCanvasStopped | Everyone in room | Notifies all participants that canvas streaming has stopped. |
room.stopCanvas();
// Publisher receives acknowledgment
@Override
public void onStoppedCanvasAck(JSONObject jsonObject) {
// Canvas streaming stopped
}
// Received by all participants
@Override
public void onCanvasStopped(EnxStream enxStream) {
// Remove the canvas view from layout
yourView.removeAllViews();
}
Note: A moderator can force stop canvas streaming using
stopAllSharing(). See
Force Stop Sharing above. Available from Android SDK v2.1.2 and later.
Annotation
Annotation allows users to draw on a remote stream. To enable annotation, canvas streaming must be enabled when creating the room: { "canvas": true }. Available from Android SDK v2.1.2 and later.
You must add the annotation toolbar to your layout XML and set the setAnnotationObserver after connecting to the room.
Add Annotation Toolbar to Layout
<enx_rtc_android.annotations.EnxAnnotationsToolbar
android:id="@+id/annotations_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
Start Annotation
EnxRoom.startAnnotation() begins annotation on a given stream object.
- Class:
EnxRoom
- Observer:
public void setAnnotationObserver(AnnotationsObserverInstance)
- Method:
public void startAnnotation(EnxStream enxStream)
- Parameter:
enxStream — the stream object to annotate.
| Callback | Delivered To | Description |
onStartAnnotationAck | Annotator | Acknowledgment to the annotator when annotation starts. |
onAnnotationStarted | Everyone in room | Notifies all participants that annotation has started. |
// Set the annotation observer after connecting to the room
room.setAnnotationObserver(annotationsObserverInstance);
// Start annotation on a stream
room.startAnnotation(enxStream);
// Annotator receives acknowledgment
@Override
public void onStartAnnotationAck(JSONObject jsonObject) {
// Annotation started — update UI
}
// Notification to all participants
@Override
public void onAnnotationStarted(EnxStream enxStream) {
// Add the annotation view to your layout
((ViewGroup) mAnnotationViewContainer).addView(enxStream.EnxPlayerView);
}
Stop Annotation
EnxRoom.stopAnnotation() stops the current annotation.
- Class:
EnxRoom
- Method:
public void stopAnnotation()
| Callback | Delivered To | Description |
onStoppedAnnotationAck | Annotator | Acknowledgment to the annotator when annotation stops. |
onAnnotationStopped | Everyone in room | Notifies all participants that annotation has stopped. |
room.stopAnnotation();
// Annotator receives acknowledgment
@Override
public void onStoppedAnnotationAck(JSONObject jsonObject) {
// Annotation stopped — update UI
}
// Notification to all participants
@Override
public void onAnnotationStopped(EnxStream enxStream) {
// Remove the annotation view from your layout
((ViewGroup) mAnnotationViewContainer).removeView(enxStream.EnxPlayerView);
}
| Error Code | Description |
| 5093 | Annotation access is denied. |
| 5094 | Repeated stopAnnotation() while a previous request is in process. |
| 5104 | Repeated startAnnotation() — annotations are already active in the room. |
| 5106 | Repeated startAnnotation() while a previous request is in process. |
| 5108 | Invalid stream passed to startAnnotation(). |
| 5109 | Failed to publish annotation stream. |
| 5112 | Annotation is only supported in landscape mode. |
Live Transcription
Live transcription converts the speech of all Active Talkers in a session to text in near real time. All endpoints that request transcription subscribe to the same transcription feed. The process starts when the first user requests it and stops when the last subscriber opts out — unless auto_transcribe is enabled at the room level, in which case it runs for the full session.
Subscription required: Live transcription is a subscription-based service. Contact your EnableX Account Manager to enable it. If not subscribed, rooms configured with live transcription settings will be rejected.
Start Live Transcription
Two methods are available to start live transcription:
startLiveTranscription(language) — starts transcription for the calling endpoint (self-transcription).
startLiveTranscriptionForRoom(language) — starts or joins room-level transcription, promoting it from self-transcription if it was already running.
When the method is called for the first time in a session, it starts the transcription process and subscribes the endpoint. Subsequent calls from other endpoints only subscribe them to the existing feed.
- Class:
EnxRoom
- Methods:
public void startLiveTranscription(String language)
public void startLiveTranscriptionForRoom(String language)
- Parameter:
language — language code string (e.g. "english_us"). Default is "english_us". See the Language Codes reference for all supported values.
| Callback | Description |
onACKStartLiveTranscription | Acknowledgment that the start request was received. |
onSelfTranscriptionOn | Notifies the endpoint that self-transcription is enabled. |
onRoomTranscriptionOn | Notifies when transcription is promoted to room-level. |
onTranscriptionEvents | Delivers live transcription events containing recognized text. |
Transcription Event Payload
The onTranscriptionEvents callback delivers a JSONObject with the following fields:
| Field | Description |
type | "speech_recognising" — intermediate event while audio is being recognized. "speech_recognised" — final event when a phrase is fully recognized (typically at a pause or speech end). |
text | The transcribed text string. |
duration | Duration from the offset at which the speech was identified. |
clientId | Client ID of the user whose speech is being recognized. |
// Start self-transcription
enxRoom.startLiveTranscription("english_us");
// Or start room-level transcription
enxRoom.startLiveTranscriptionForRoom("english_us");
// Acknowledgment of start request
@Override
public void onACKStartLiveTranscription(JSONObject jsonObject) {
// Start request acknowledged
}
// Self-transcription is now active
@Override
public void onSelfTranscriptionOn(JSONObject jsonObject) {
// This endpoint is now receiving transcription
}
// Room-level transcription is active
@Override
public void onRoomTranscriptionOn(JSONObject jsonObject) {
// All subscribed endpoints are receiving transcription
}
// Receive transcription events
@Override
public void onTranscriptionEvents(JSONObject jsonObject) {
String type = jsonObject.getString("type"); // "speech_recognising" or "speech_recognised"
String text = jsonObject.getString("text"); // Transcribed text
String clientId = jsonObject.getString("clientId"); // Speaker's client ID
// Display or process the transcribed text
}
| Error Code | Description |
| 3002 | Live transcription subscription is not enabled. |
| 3002 | Live transcription is already in progress. |
Stop Live Transcription
EnxRoom.stopLiveTranscription() unsubscribes the calling endpoint from the live transcription feed. When the last subscribed endpoint calls this method, the transcription process stops in the room — unless auto_transcribe is enabled at the room level, in which case it continues until the session ends.
- Class:
EnxRoom
- Method:
public void stopLiveTranscription()
| Callback | Description |
onACKStopLiveTranscription | Acknowledgment that the stop request was received. |
onSelfTranscriptionOff | Notifies the endpoint that self-transcription has been turned off. |
onRoomTranscriptionOff | Notifies when room-level transcription has been stopped. |
enxRoom.stopLiveTranscription();
// Acknowledgment of stop request
@Override
public void onACKStopLiveTranscription(JSONObject jsonObject) {
// Stop request acknowledged
}
// This endpoint is no longer receiving transcription
@Override
public void onSelfTranscriptionOff(JSONObject jsonObject) {
// Hide transcription UI
}
// Room-level transcription has been stopped
@Override
public void onRoomTranscriptionOff(JSONObject jsonObject) {
// Transcription has ended for all participants
}
| Error Code | Description |
| 3001 | Live transcription request not found — transcription may not have been started. |