Class: Easyrtc_ft

Easyrtc_ft

Easyrtc_ft.

new Easyrtc_ft() → {Easyrtc_ft}

Returns:
the new easyrtc instance.
Type
Easyrtc_ft

Members

<static> errCodes :Object

Error codes that the EasyRTC will use in the errorCode field of error object passed to error handler set by easyrtc.setOnError. The error codes are short printable strings.
Type:
  • Object

<static> saveAs

This is a wrapper around Eli Grey's saveAs function. This saves to the browser's downloads directory.

Methods

<static> buildDragNDropRegion(droptargetName, filesHandler)

Establish an area as a drag-n-drop drop site for files.
Parameters:
Name Type Description
droptargetName DOMString the id of the drag-and-drop site or the actual DOM object.
filesHandler function function that accepts an array of File's.

<static> buildFileReceiver(acceptRejectCB, blobAcceptor, statusCB, options)

Enable datachannel based file receiving. The received blobs get passed to the statusCB in the 'eof' typed message.
Parameters:
Name Type Description
acceptRejectCB function this function is called when another peer (otherGuy) offers to send you a list of files. this function should call it's wasAccepted function with true to allow those files to be sent, or false to disallow them.
blobAcceptor function this function is called three arguments arguments: the suppliers easyrtcid, a blob and a filename. It is responsible for saving the blob to the file, usually using easyrtc_ft.saveAs.
statusCB type this function is called with the current state of file receiving. It is passed two arguments: otherGuy - the easyrtcid of the person sending the files. * msg - one of the following structures: {status:"done", reason:"accept_failed"} {status:"done", reason:"success"} {status:"done", reason:"cancelled"} {status:"eof"}, {status:"started_file, name:"filename"} {status:"progress", name:filename, received:received_size_in_bytes, size:file_size_in_bytes }
options is currently ignored.
Example
easyrtc_ft.buildFileReceiver(
      function(otherGuy, filenamelist, wasAccepted) {  wasAccepted(true);},
      function(otherGuy, blob, filename) { easyrtc_ft.saveAs(blob, filename);},
      function(otherGuy, status) {  console.log("status:" + JSON.stringify(status))}
    );

<static> buildFileSender(destUser, progressListener, options) → {function}

Builds a function that can be used to send a group of files to a peer.
Parameters:
Name Type Description
destUser String easyrtcid of the person being sent to.
progressListener function if provided, is called with the following objects: {status:"waiting"} // once a file offer has been sent but not accepted or rejected yet {status:"started_file", name: filename} {status:"working", name:filename, position:position_in_file, size:size_of_current_file, numFiles:number_of_files_left} {status:"cancelled"} // if the remote user cancels the sending {status:"done"} // when the file is done the progressListener should always return true for normal operation, false to cancel a filetransfer.
options Object overide default file transfer settings maxPacketSize is the size (before base64 encoding) that is sent in a single data channel message, in bytes. maxChunkSize is the amount read from a file at a time, in bytes. ackThreshold is the amount of data that can be sent before an ack is received from the party we're sending to, bytes. maxChunkSize should be a multiple of maxPacketSize. ackThreshold should be several times larger than maxChunkSize. For network paths that have greater latency, increase ackThreshold further.
Returns:
an object that accepts an array of File (the Files to be sent), and a boolean
Type
function
Documentation generated by JSDoc 3.6.11 on 2023-05-30T12:08:53+00:00