A wrapper class that manages a connection to PrivMX Bridge and provides access to various APIs, including Threads, Stores, and Inboxes.
The PrivMXEndpoint class is designed to encapsulate and manage a single connection to PrivMX. It provides access to different APIs for handling Threads, Stores, and Inboxes, based on the modules that are enabled during initialization. It also supports asynchronous operations like uploading and downloading files, and allows for managing callbacks for events.
Initializes a new instance of PrivMXEndpoint with a connection to PrivMX Bridge and optional modules.
This method sets up the connection and, based on the provided modules, initializes the APIs for handling Threads, Stores, and Inboxes.
Initializes a new instance of PrivMXEndpoint with a connection to PrivMX Bridge and optional modules.
This method sets up the connection and, based on the provided modules, initializes the APIs for handling Threads, Stores, and Inboxes.
Initializes a new instance of PrivMXEndpoint with a public connection to the PrivMX Bridge and optional modules.
This method sets up the connection and, based on the provided modules, initializes the APIs for handling threads, stores, and inboxes. Using a Public (anonymous) connection. Take note that this is only useful for Inboxes
Initializes a new instance of PrivMXEndpoint with a public connection to the PrivMX Bridge and optional modules.
This method sets up the connection and, based on the provided modules, initializes the APIs for handling threads, stores, and inboxes. Using a Public (anonymous) connection. Take note that this is only useful for Inboxes
Begins uploading a new file using PrivMXStoreFileHandler, which manages file uploads.
This method uploads a file to a specified store using a FileHandle. It supports uploading large files in chunks and provides a callback for tracking the progress.
Begins uploading a new file from an in-memory buffer using PrivMXStoreFileHandler.
This method uploads file content from a Data buffer to a specified Store. It supports chunked uploads and provides a callback for progress tracking.
/ Begins uploading an updated file using PrivMXStoreFileHandler.
This method updates an existing file in a store with new content and metadata, supporting chunked uploads for large files.
Begins uploading an updated file from an in-memory buffer using PrivMXStoreFileHandler.
This method updates an existing file in a store with new content and metadata, supporting chunked uploads for large files.
Begins downloading a file to the local filesystem using PrivMXStoreFileHandler.
This method downloads a file from a Store to the local filesystem using a FileHandle. It supports downloading files in chunks and provides a callback for progress tracking.
public func startDownloadingToFile( _ file:FileHandle, from fileId:String, withChunksOf chunkSize: Int64 = PrivMXStoreFileHandler.RecommendedChunkSize, onChunkDownloaded:(@escaping@Sendable(Int)-> Void)={_ in} )async throws -> String
Name
Type
Description
file
FileHandle
A local `FileHandle` representing the destination file.
fileId
String
The identifier of the file to be downloaded.
chunkSize
Int64
onChunkDownloaded
(@escaping @Sendable (Int) -> Void)
A callback that is called after each chunk download is completed.
Type
Description
String
The identifier of the downloaded file as a `String`.
Begins downloading a file to the local filesystem using InboxFileHandler.
This method downloads a file from an Inbox to the local filesystem using a FileHandle. It supports downloading files in chunks and provides a callback for progress tracking.
public func startDownloadingToFileFromInbox( _ file:FileHandle, from fileId:String, withChunksOf chunkSize: Int64 = InboxFileHandler.RecommendedChunkSize, onChunkDownloaded:(@escaping@Sendable(Int)-> Void)={_ in} )async throws -> String
Name
Type
Description
file
FileHandle
A local `FileHandle` representing the destination file.
fileId
String
The identifier of the file to be downloaded.
chunkSize
Int64
The size of a chunk to be used
onChunkDownloaded
(@escaping @Sendable (Int) -> Void)
A callback that is called after each chunk download is completed.
Type
Description
String
The identifier of the downloaded file as a `String`.
Begins downloading a file to in-memory buffer.
This method downloads a file from a store to the local in-memory buffer. It supports downloading files in chunks and provides a callback for progress tracking.
public func startDownloadingToBufferFromInbox( from fileId:String, withChunksOf chunkSize: Int64 = PrivMXStoreFileHandler.RecommendedChunkSize, onChunkDownloaded:(@escaping@Sendable(Int)-> Void)={_ in} )async throws -> Data
Name
Type
Description
fileId
String
The identifier of the file to be downloaded.
chunkSize
Int64
onChunkDownloaded
(@escaping @Sendable (Int) -> Void)
A callback that is called after each chunk download is completed.
Type
Description
Data
The identifier of the downloaded file as a `String`.
Begins downloading a file to in-memory buffer.
This method downloads a file from a store to the local in-memory buffer. It supports downloading files in chunks and provides a callback for progress tracking.
public func startDownloadingToBuffer( from fileId:String, withChunksOf chunkSize: Int64 = PrivMXStoreFileHandler.RecommendedChunkSize, onChunkDownloaded:(@escaping@Sendable(Int)-> Void)={_ in} )async throws -> Data
Name
Type
Description
fileId
String
The identifier of the file to be downloaded.
chunkSize
Int64
onChunkDownloaded
(@escaping @Sendable (Int) -> Void)
A callback that is called after each chunk download is completed.
Type
Description
Data
The identifier of the downloaded file as a `String`.
Deletes a specific Callback.
Note that this is an expensive operation. If there are no callbacks left for events from a particular channel, Connection.unsubscribeFromChannel(_:) is called, which means no Events from that Channel will arrive.
public func deleteCallbacks( identified id:String )-> Void
Removes all callbacks for a particular Event type.
If there are no callbacks left for events from a particular channel, Connection.unsubscribeFromChannel(_:) is called, which means no Events from that Channel will arrive.
public func clearCallbacks( for type:PMXEvent.Type )-> Void
Name
Type
Description
type
PMXEvent.Type
the type of Event, for which callbacks should be removed.
Removes all registered callbacks for Events from selected Channel
Once all callbacks are removed, Connection.unsubscribeFromChannel(_:) is called, which means no Events from that Channel will arrive.
public func clearCallbacks( for channel:EventChannel )-> Void
Name
Type
Description
channel
EventChannel
the EventChannel, from which events should no longer be received