SDK Version 2.0.1
AnsuR Technologies ASMIRA SDK
Loading...
Searching...
No Matches
Room file transfer

Typedefs

typedef void(*) asdk::RoomFileAvailableFunc(const uint32_t roomID, const uint64_t hash, const char *fileName, const uint32_t fileSize, const uint32_t originClientID, const uint64_t utc, void *opaque)
 A room file became available to download (pull model).
typedef void(*) asdk::RoomFileDeletedFunc(const uint32_t roomID, const uint64_t hash, void *opaque)
 A room file (roomID, hash) was deleted for the whole room; drop any reference to it.
typedef void(*) asdk::RoomFileDownloadedFunc(const uint32_t roomID, const uint64_t hash, const char *fileName, const uint8_t *data, const uint32_t size, void *opaque)
 A requested room-file download finished and hash-verified: data/size hold the file bytes (valid only for the duration of the callback).
typedef void(*) asdk::RoomFileProgressFunc(const uint32_t roomID, const uint64_t hash, const char *fileName, const RoomFileDirection direction, const uint32_t transferred, const uint32_t total, void *opaque)
 Bytes moved for a transfer in either direction.
typedef void(*) asdk::RoomFileSentFunc(const uint32_t roomID, const uint64_t hash, const char *fileName, void *opaque)
 An upload reached the server, which now announces it to the other room members.
typedef void(*) asdk::RoomFileErrorFunc(const uint32_t roomID, const uint64_t hash, const char *fileName, const RoomFileError error, void *opaque)
 A transfer failed, anything already received for it has been discarded.

Enumerations

enum  asdk::RoomFileDirection {
  asdk::RoomFileDirectionUndef ,
  asdk::RoomFileDirectionSend ,
  asdk::RoomFileDirectionReceive
}
 Room file transfer direction. More...
enum  asdk::RoomFileError {
  asdk::RoomFileErrorUndef ,
  asdk::RoomFileErrorCanceled ,
  asdk::RoomFileErrorHashMismatch ,
  asdk::RoomFileErrorFile
}
 Room file transfer failure reason. More...

Functions

Status asdk::sdk_t::RoomFileSend (const uint32_t roomID, const char *fileName, const void *data, const uint32_t size)
 Uploads a file to a room from memory.
Status asdk::sdk_t::RoomFileSendFromPath (const uint32_t roomID, const char *filePath)
 Uploads a file to a room from disk.
Status asdk::sdk_t::RoomFileSendResumeFromPath (const uint32_t roomID, const char *filePath)
 Resumes an interrupted upload of a file from disk.
Status asdk::sdk_t::RoomFileDownload (const uint32_t roomID, const uint64_t hash)
 Downloads a room file announced by RoomFileAvailableFunc.
Status asdk::sdk_t::RoomFileDownloadResume (const uint32_t roomID, const uint64_t hash, const char *fileName, const uint32_t totalSize, const void *haveBytes, const uint32_t haveCount)
 Resumes a room file download the caller already has part of.
Status asdk::sdk_t::RoomFileCancel (const uint32_t roomID, const uint64_t hash)
 Cancels a room file transfer in either direction.
Status asdk::sdk_t::RoomFileDelete (const uint32_t roomID, const uint64_t hash)
 Deletes a shared room file for the whole room.
void asdk::sdk_t::SetRoomFileAvailableCallback (RoomFileAvailableFunc func, void *opaque=nullptr)
 Room File Available callback.
void asdk::sdk_t::SetRoomFileDeletedCallback (RoomFileDeletedFunc func, void *opaque=nullptr)
 Room File Deleted callback.
void asdk::sdk_t::SetRoomFileDownloadedCallback (RoomFileDownloadedFunc func, void *opaque=nullptr)
 Room File Downloaded callback.
void asdk::sdk_t::SetRoomFileProgressCallback (RoomFileProgressFunc func, void *opaque=nullptr)
 Room File Progress callback.
void asdk::sdk_t::SetRoomFileSentCallback (RoomFileSentFunc func, void *opaque=nullptr)
 Room File Sent callback.
void asdk::sdk_t::SetRoomFileErrorCallback (RoomFileErrorFunc func, void *opaque=nullptr)
 Room File Error callback.

Detailed Description

Sharing files with a room: upload from memory or disk, download, resume, cancel and delete.

Typedef Documentation

◆ RoomFileAvailableFunc

typedef void(*) asdk::RoomFileAvailableFunc(const uint32_t roomID, const uint64_t hash, const char *fileName, const uint32_t fileSize, const uint32_t originClientID, const uint64_t utc, void *opaque)

A room file became available to download (pull model).

Identify it by (roomID, hash); pass that pair to sdk_t::RoomFileDelete to remove it (privileged, server-enforced). originClientID is the room client id that shared it (matching RoomClientAdded, 0 = server), utc the Unix time it was shared - both handy for a "who/when" column in a file list.

Definition at line 880 of file asmirasdk.h.

◆ RoomFileDeletedFunc

typedef void(*) asdk::RoomFileDeletedFunc(const uint32_t roomID, const uint64_t hash, void *opaque)

A room file (roomID, hash) was deleted for the whole room; drop any reference to it.

Definition at line 886 of file asmirasdk.h.

◆ RoomFileDownloadedFunc

typedef void(*) asdk::RoomFileDownloadedFunc(const uint32_t roomID, const uint64_t hash, const char *fileName, const uint8_t *data, const uint32_t size, void *opaque)

A requested room-file download finished and hash-verified: data/size hold the file bytes (valid only for the duration of the callback).

Triggered by room_file_download.

Definition at line 891 of file asmirasdk.h.

◆ RoomFileProgressFunc

typedef void(*) asdk::RoomFileProgressFunc(const uint32_t roomID, const uint64_t hash, const char *fileName, const RoomFileDirection direction, const uint32_t transferred, const uint32_t total, void *opaque)

Bytes moved for a transfer in either direction.

A download ends with either RoomFileDownloadedFunc or RoomFileErrorFunc, an upload with RoomFileSentFunc.

Definition at line 897 of file asmirasdk.h.

◆ RoomFileSentFunc

typedef void(*) asdk::RoomFileSentFunc(const uint32_t roomID, const uint64_t hash, const char *fileName, void *opaque)

An upload reached the server, which now announces it to the other room members.

Definition at line 904 of file asmirasdk.h.

◆ RoomFileErrorFunc

typedef void(*) asdk::RoomFileErrorFunc(const uint32_t roomID, const uint64_t hash, const char *fileName, const RoomFileError error, void *opaque)

A transfer failed, anything already received for it has been discarded.

Definition at line 908 of file asmirasdk.h.

Enumeration Type Documentation

◆ RoomFileDirection

Room file transfer direction.

Enumerator
RoomFileDirectionUndef 

Undefined

RoomFileDirectionSend 

Upload, started with RoomFileSend/RoomFileSendFromPath

RoomFileDirectionReceive 

Download, started with RoomFileDownload

Examples
example_complete.cpp.

Definition at line 273 of file asmirasdk.h.

◆ RoomFileError

Room file transfer failure reason.

Enumerator
RoomFileErrorUndef 

Undefined

RoomFileErrorCanceled 

The server dropped the transfer or holds no copy to send

RoomFileErrorHashMismatch 

Every byte arrived but the content did not verify

RoomFileErrorFile 

A local file could not be read, is empty or too large

Examples
example_complete.cpp.

Definition at line 283 of file asmirasdk.h.

Function Documentation

◆ RoomFileSend()

Status asdk::sdk_t::RoomFileSend ( const uint32_t roomID,
const char * fileName,
const void * data,
const uint32_t size )
inline

Uploads a file to a room from memory.

The whole file is held in memory until it has been queued, prefer RoomFileSendFromPath for anything large. The server hashes the content, stores it and announces it to the other room members, which then choose to download it. Requires a joined room and DeviceCapabilityFileTransfer on the connection. Progress arrives on RoomFileProgressFunc, completion on RoomFileSentFunc.

Parameters
roomIDRoom ID to share the file in.
fileNameFile name shown to the other members.
dataFile content.
sizeFile content size in bytes.
Returns
Status, StatusOK once the upload is queued

Definition at line 1240 of file asmirasdk.h.

References asdk::StatusErrorHandle.

◆ RoomFileSendFromPath()

Status asdk::sdk_t::RoomFileSendFromPath ( const uint32_t roomID,
const char * filePath )
inline

Uploads a file to a room from disk.

Same as RoomFileSend but the content is hashed and streamed straight from disk, so the file is never held in memory in full. The name shown to the other members is taken from the path. The file has to stay in place and unchanged until the upload completes.

Parameters
roomIDRoom ID to share the file in.
filePathPath to the local file.
Returns
Status, StatusErrorFile if the path cannot be read

Definition at line 1260 of file asmirasdk.h.

References asdk::StatusErrorHandle.

◆ RoomFileSendResumeFromPath()

Status asdk::sdk_t::RoomFileSendResumeFromPath ( const uint32_t roomID,
const char * filePath )
inline

Resumes an interrupted upload of a file from disk.

Completion arrives on RoomFileSentFunc, progress on RoomFileProgressFunc, as for a normal upload. Requires a joined room and DeviceCapabilityFileTransfer.

Parameters
roomIDRoom ID to share the file in.
filePathPath to the local file, unchanged since the interrupted upload.
Returns
Status, StatusErrorFile if the path cannot be read

Definition at line 1277 of file asmirasdk.h.

References asdk::StatusErrorHandle.

◆ RoomFileDownload()

Status asdk::sdk_t::RoomFileDownload ( const uint32_t roomID,
const uint64_t hash )
inline

Downloads a room file announced by RoomFileAvailableFunc.

Identify the file by the (roomID, hash) pair from that callback. The content is buffered in memory and handed over by RoomFileDownloadedFunc once every byte arrived and the hash verified, so keep the announced file size in mind. Progress arrives on RoomFileProgressFunc, failures on RoomFileErrorFunc.

Parameters
roomIDRoom ID from RoomFileAvailableFunc.
hashFile hash from RoomFileAvailableFunc.
Returns
Status

Definition at line 1296 of file asmirasdk.h.

References asdk::StatusErrorHandle.

◆ RoomFileDownloadResume()

Status asdk::sdk_t::RoomFileDownloadResume ( const uint32_t roomID,
const uint64_t hash,
const char * fileName,
const uint32_t totalSize,
const void * haveBytes,
const uint32_t haveCount )
inline

Resumes a room file download the caller already has part of.

Like RoomFileDownload, but the caller supplies the leading bytes it already holds (for example a partial file persisted from an interrupted download). The server streams only the remaining bytes from haveCount onward; the SDK prepends the supplied bytes, so the completed file is still delivered whole and hash verified through RoomFileDownloadedFunc. The bytes must be the exact prefix that was announced, or the transfer fails the hash check (RoomFileErrorHashMismatch). Pass a haveCount of zero to download from the start (identical to RoomFileDownload).

Parameters
roomIDRoom ID from RoomFileAvailableFunc.
hashFile hash from RoomFileAvailableFunc.
fileNameFile name, as announced (used for the completion and progress callbacks).
totalSizeTotal file size, as announced (used for progress reporting).
haveBytesBytes already held, the exact leading portion of the file.
haveCountNumber of bytes already held.
Returns
Status

Definition at line 1322 of file asmirasdk.h.

References asdk::StatusErrorHandle.

◆ RoomFileCancel()

Status asdk::sdk_t::RoomFileCancel ( const uint32_t roomID,
const uint64_t hash )
inline

Cancels a room file transfer in either direction.

The server stops streaming and anything already received is discarded. No RoomFileErrorFunc follows a cancel that was requested here.

Parameters
roomIDRoom ID of the transfer.
hashFile hash of the transfer.
Returns
Status

Definition at line 1342 of file asmirasdk.h.

References asdk::StatusErrorHandle.

◆ RoomFileDelete()

Status asdk::sdk_t::RoomFileDelete ( const uint32_t roomID,
const uint64_t hash )
inline

Deletes a shared room file for the whole room.

StatusOK means the request was sent, success shows up as RoomFileDeletedFunc.

Parameters
roomIDRoom ID from RoomFileAvailableFunc.
hashFile hash from RoomFileAvailableFunc.
Returns
Status, StatusErrorNotPermitted when this user cannot delete

Definition at line 1358 of file asmirasdk.h.

References asdk::StatusErrorHandle.

◆ SetRoomFileAvailableCallback()

void asdk::sdk_t::SetRoomFileAvailableCallback ( RoomFileAvailableFunc func,
void * opaque = nullptr )
inline

Room File Available callback.

A file was shared in the room, pass its (roomID, hash) to RoomFileDownload to get it.

Parameters
funcCallback to install.
opaqueCaller data passed back unchanged to every invocation.

Definition at line 1567 of file asmirasdk.h.

◆ SetRoomFileDeletedCallback()

void asdk::sdk_t::SetRoomFileDeletedCallback ( RoomFileDeletedFunc func,
void * opaque = nullptr )
inline

Room File Deleted callback.

Parameters
funcCallback to install.
opaqueCaller data passed back unchanged to every invocation.

Definition at line 1579 of file asmirasdk.h.

◆ SetRoomFileDownloadedCallback()

void asdk::sdk_t::SetRoomFileDownloadedCallback ( RoomFileDownloadedFunc func,
void * opaque = nullptr )
inline

Room File Downloaded callback.

A download finished and hash verified, the data is valid for the duration of the call.

Parameters
funcCallback to install.
opaqueCaller data passed back unchanged to every invocation.

Definition at line 1593 of file asmirasdk.h.

◆ SetRoomFileProgressCallback()

void asdk::sdk_t::SetRoomFileProgressCallback ( RoomFileProgressFunc func,
void * opaque = nullptr )
inline

Room File Progress callback.

Parameters
funcCallback to install.
opaqueCaller data passed back unchanged to every invocation.

Definition at line 1605 of file asmirasdk.h.

◆ SetRoomFileSentCallback()

void asdk::sdk_t::SetRoomFileSentCallback ( RoomFileSentFunc func,
void * opaque = nullptr )
inline

Room File Sent callback.

Parameters
funcCallback to install.
opaqueCaller data passed back unchanged to every invocation.

Definition at line 1617 of file asmirasdk.h.

◆ SetRoomFileErrorCallback()

void asdk::sdk_t::SetRoomFileErrorCallback ( RoomFileErrorFunc func,
void * opaque = nullptr )
inline

Room File Error callback.

Parameters
funcCallback to install.
opaqueCaller data passed back unchanged to every invocation.

Definition at line 1629 of file asmirasdk.h.