new TransferredFile()
A file in the process of being transferred.
These are stored in the ServerConnection.transferredFiles dictionary.
State transitions:
- Source:
Example
'' -> inviting -> connecting -> connected -> done -> closed
any -> cancelled -> closed
Members
candidates :Array.<RTCIceCandidateInit>
Buffered remote ICE candidates.
Type:
- Array.<RTCIceCandidateInit>
- Source:
data :Array.<(Blob|ArrayBuffer)>
The data received to date, stored as a list of blobs or array buffers,
depending on what the browser supports.
Type:
- Array.<(Blob|ArrayBuffer)>
- Source:
datalen :number
The total size of the data received to date.
Type:
- number
- Source:
dc :RTCDataChannel
The datachannel used for the transfer.
Type:
- RTCDataChannel
- Source:
file :File
The file being uploaded. Unused for downloads.
Type:
- File
- Source:
id :string
The id of this file transfer.
Type:
- string
- Source:
mimetype :string
The MIME type of the file being transferred.
Type:
- string
- Source:
name :string
The name of the file being transferred.
Type:
- string
- Source:
onevent
The main filetransfer callback.
This is called whenever the state of the transfer changes,
but may also be called multiple times in a single state, for example
in order to display a progress bar. Call this.cancel in order
to cancel the transfer.
- Source:
pc :RTCPeerConnection
The peer connection used for the transfer.
Type:
- RTCPeerConnection
- Source:
sc :ServerConnection
The server connection this file is associated with.
Type:
- Source:
size :number
The size in bytes of the file being transferred.
Type:
- number
- Source:
state :string
The state of this file transfer. See the description of the
constructor for possible state transitions.
Type:
- string
- Source:
up :boolean
True if this is an upload.
Type:
- boolean
- Source:
userid :string
The id of the remote peer.
Type:
- string
- Source:
username :string
The username of the remote peer.
Type:
- string
- Source:
version :string
The negotiated file-transfer protocol version.
This is the version of the file-transfer protocol, and is not
necessarily equal to the version of the Galene protocol used by the
server connection.
Type:
- string
- Source:
Methods
answer(sdp)
Negotiate a file transfer on the sender side.
Don't call this, it is called automatically we receive an offer.
Parameters:
Name | Type | Description |
---|---|---|
sdp |
string |
- Source:
bufferData(data)
Buffer a chunk of data received during a file transfer.
Do not call this, it is called automatically when data is received.
Parameters:
Name | Type | Description |
---|---|---|
data |
Blob | ArrayBuffer |
- Source:
cancel(messageopt)
Cancel a file transfer.
Depending on the state, this will either forcibly close the connection,
send a handshake, or do nothing. It will set the state to cancelled.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
message |
string | Error |
<optional> |
- Source:
close()
Close a file transfer and remove it from the transferredFiles dictionary.
Do not call this, call 'cancel' instead.
- Source:
event(state, dataopt)
Set the file's state, and call the onevent callback.
This calls the callback even if the state didn't change, which is
useful if the client needs to display a progress bar.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
state |
string | ||
data |
any |
<optional> |
- Source:
fail(dataopt)
Forcibly terminate a file transfer.
This is like cancel, but will not attempt to handshake.
Use cancel instead of this, unless you know what you are doing.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
data |
string | Error |
<optional> |
- Source:
fullid()
The full id of this file transfer, used as a key in the transferredFiles
dictionary.
- Source:
getBufferedData() → {Blob}
Retreive the data buffered during a file transfer. Don't call this.
- Source:
Returns:
- Type
- Blob
receive()
Receive a file.
Call this after the onfiletransfer callback has yielded an incoming
file (up field set to false). If you wish to reject the file transfer,
call cancel instead.
- Source:
receiveData(data)
Called whenever we receive a chunk of data. Don't call this.
Parameters:
Name | Type | Description |
---|---|---|
data |
Blob | ArrayBuffer |
- Source:
receiveFile(sdp)
Called after we receive an answer. Don't call this.
Parameters:
Name | Type | Description |
---|---|---|
sdp |
string |
- Source:
send()
Transfer file data. Don't call this, it is called automatically
after negotiation completes.
- Source: