Class TransferredFile
Defined in: protocol.js.
Constructor Attributes | Constructor Name and Description |
---|---|
TransferredFile(sc, userid, id, up, username, name, mimetype, size)
A file in the process of being transferred.
|
Field Attributes | Field Name and Description |
---|---|
Negotiate a file transfer on the sender side.
|
|
Buffered remote ICE candidates.
|
|
The data received to date, stored as a list of blobs or array buffers,
depending on what the browser supports.
|
|
The total size of the data received to date.
|
|
The datachannel used for the transfer.
|
|
The file being uploaded.
|
|
The id of this file transfer.
|
|
The MIME type of the file being transferred.
|
|
The name of the file being transferred.
|
|
The main filetransfer callback.
|
|
The peer connection used for the transfer.
|
|
Receive a file.
|
|
Called whenever we receive a chunk of data.
|
|
Called after we receive an answer.
|
|
The server connection this file is associated with.
|
|
Transfer file data.
|
|
The size in bytes of the file being transferred.
|
|
The state of this file transfer.
|
|
True if this is an upload.
|
|
The id of the remote peer.
|
|
The username of the remote peer.
|
Method Attributes | Method Name and Description |
---|---|
bufferData(data)
Buffer a chunk of data received during a file transfer.
|
|
cancel(data)
Cancel a file transfer.
|
|
close()
Close a file transfer and remove it from the transferredFiles dictionary.
|
|
event(state, data)
Set the file's state, and call the onevent callback.
|
|
fail(data)
Forcibly terminate a file transfer.
|
|
fullid()
The full id of this file transfer, used as a key in the transferredFiles
dictionary.
|
|
Retreive the data buffered during a file transfer.
|
Class Detail
TransferredFile(sc, userid, id, up, username, name, mimetype, size)
A file in the process of being transferred.
These are stored in the ServerConnection.transferredFiles dictionary.
State transitions:
'' -> inviting -> connecting -> connected -> done -> closed any -> cancelled -> closed
- Parameters:
- sc
- userid
- id
- up
- username
- name
- mimetype
- size
Field Detail
answer
Negotiate a file transfer on the sender side. Don't call this.
candidates
Buffered remote ICE candidates.
data
The data received to date, stored as a list of blobs or array buffers,
depending on what the browser supports.
datalen
The total size of the data received to date.
dc
The datachannel used for the transfer.
file
The file being uploaded. Unused for downloads.
id
The id of this file transfer.
mimetype
The MIME type of the file being transferred.
name
The name of the file being transferred.
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.
pc
The peer connection used for the transfer.
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.
receiveData
Called whenever we receive a chunk of data. Don't call this.
receiveFile
Called after we receive an answer. Don't call this.
sc
The server connection this file is associated with.
send
Transfer file data. Don't call this, it is called automatically
after negotiation completes.
size
The size in bytes of the file being transferred.
state
The state of this file transfer. See the description of the
constructor for possible state transitions.
up
True if this is an upload.
userid
The id of the remote peer.
username
The username of the remote peer.
Method Detail
bufferData(data)
Buffer a chunk of data received during a file transfer. Do not call this.
- Parameters:
- {Blob|ArrayBuffer} data
cancel(data)
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:
- {string|Error} data Optional
close()
Close a file transfer and remove it from the transferredFiles dictionary.
Do not call this, call 'cancel' instead.
event(state, data)
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:
- {string} state
- {any} data Optional
fail(data)
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:
- {string|Error} data Optional
fullid()
The full id of this file transfer, used as a key in the transferredFiles
dictionary.
{Blob}
getBufferedData()
Retreive the data buffered during a file transfer. Don't call this.
- Returns:
- {Blob}