Class Client
A client API for uploading and downloading files from a Cache Server
Namespace: UnityEditor.Build.CacheServer
Syntax
public class Client
Constructors
Client(String, Int32)
Create a new Cache Server client
Declaration
public Client(string host, int port = 8126)
Parameters
Type | Name | Description |
---|---|---|
String | host | The host name or IP of the Cache Server. |
Int32 | port | The port number of the Cache Server. Default port is 8126. |
Properties
DownloadQueueLength
Returns the number of items in the download queue
Declaration
public int DownloadQueueLength { get; }
Property Value
Type | Description |
---|---|
Int32 |
Methods
BeginTransaction(FileId)
Begin an upload transaction for an asset. Transactions in process can be interupted by calling BeginTransaction again before calling EndTransaction.
Declaration
public void BeginTransaction(FileId fileId)
Parameters
Type | Name | Description |
---|---|---|
FileId | fileId |
Close()
Close the connection to the Cache Server. Sends the 'quit' command and closes the network stream.
Declaration
public void Close()
Connect()
Connects to the Cache Server and sends a protocol version handshake.
Declaration
public void Connect()
Exceptions
Type | Condition |
---|---|
Exception |
Connect(Int32)
Connects to the Cache Server and sends a protocol version handshake. A TimeoutException is thrown if the connection cannot
be established within timeoutMs
milliseconds.
Declaration
public void Connect(int timeoutMs)
Parameters
Type | Name | Description |
---|---|---|
Int32 | timeoutMs |
Exceptions
Type | Condition |
---|---|
TimeoutException | |
Exception |
EndTransaction()
Commit the uploaded files to the Cache Server. Will throw an exception if not preceeded by BeginTransaction.
Declaration
public void EndTransaction()
Exceptions
Type | Condition |
---|---|
TransactionIsolationException |
QueueDownload(IDownloadItem)
Send a download request to the Cache Server. Listen to the DownloadComplete event to read the results.
Declaration
public void QueueDownload(IDownloadItem downloadItem)
Parameters
Type | Name | Description |
---|---|---|
IDownloadItem | downloadItem | The IDownloadItem that specifies which file to download |
ResetDownloadFinishedEventHandler()
Remove all listeners from the DownloadFinished event
Declaration
public void ResetDownloadFinishedEventHandler()
Upload(FileType, Stream)
Upload from the given stream for the given FileType. Will throw an exception if not preceeded by BeginTransaction.
Declaration
public void Upload(FileType type, Stream readStream)
Parameters
Type | Name | Description |
---|---|---|
FileType | type | |
Stream | readStream |
Exceptions
Type | Condition |
---|---|
TransactionIsolationException | |
ArgumentException |
Events
DownloadFinished
Event fired when a queued download request finishes.
Declaration
public event EventHandler<DownloadFinishedEventArgs> DownloadFinished
Event Type
Type | Description |
---|---|
EventHandler<DownloadFinishedEventArgs> |