connect

package
v5.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 10, 2022 License: BSD-2-Clause, BSD-2-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Params

type Params struct {
	// NotifyUponCompletion indicates if a final notification message is sent
	// to the recipient on completion of file transfer. If true, the ping is
	// sent.
	NotifyUponCompletion bool
}

Params contains parameters used for connection file transfer.

func DefaultParams

func DefaultParams() Params

DefaultParams returns a Params object filled with the default values.

func GetParameters

func GetParameters(params string) (Params, error)

GetParameters returns the default network parameters, or override with given parameters, if set. Returns an error if provided invalid JSON. If the JSON is valid but does not match the Params structure, the default parameters will be returned.

type Wrapper

type Wrapper struct {
	// contains filtered or unexported fields
}

Wrapper handles the sending and receiving of file transfers using the Connection interface messages to inform the recipient of incoming file transfers.

func NewWrapper

func NewWrapper(receiveCB ft.ReceiveCallback, p Params, ft ft.FileTransfer,
	conn connection, cmix ft.Cmix) (*Wrapper, error)

NewWrapper generates a new file transfer manager using connection E2E.

func (*Wrapper) CloseSend

func (w *Wrapper) CloseSend(tid *ftCrypto.TransferID) error

CloseSend deletes a file from the internal storage once a transfer has completed or reached the retry limit. Returns an error if the transfer has not run out of retries.

This function should be called once a transfer completes or errors out (as reported by the progress callback).

func (*Wrapper) MaxFileNameLen

func (w *Wrapper) MaxFileNameLen() int

MaxFileNameLen returns the max number of bytes allowed for a file name.

func (*Wrapper) MaxFileSize

func (w *Wrapper) MaxFileSize() int

MaxFileSize returns the max number of bytes allowed for a file.

func (*Wrapper) MaxFileTypeLen

func (w *Wrapper) MaxFileTypeLen() int

MaxFileTypeLen returns the max number of bytes allowed for a file type.

func (*Wrapper) MaxPreviewSize

func (w *Wrapper) MaxPreviewSize() int

MaxPreviewSize returns the max number of bytes allowed for a file preview.

func (*Wrapper) Receive

func (w *Wrapper) Receive(tid *ftCrypto.TransferID) ([]byte, error)

Receive returns the full file on the completion of the transfer. It deletes internal references to the data and unregisters any attached progress callback. Returns an error if the transfer is not complete, the full file cannot be verified, or if the transfer cannot be found.

Receive can only be called once the progress callback returns that the file transfer is complete.

func (*Wrapper) RegisterReceivedProgressCallback

func (w *Wrapper) RegisterReceivedProgressCallback(tid *ftCrypto.TransferID,
	progressCB ft.ReceivedProgressCallback, period time.Duration) error

RegisterReceivedProgressCallback allows for the registration of a callback to track the progress of an individual received file transfer. This must be done when a new transfer is received on the ReceiveCallback.

func (*Wrapper) RegisterSentProgressCallback

func (w *Wrapper) RegisterSentProgressCallback(tid *ftCrypto.TransferID,
	progressCB ft.SentProgressCallback, period time.Duration) error

RegisterSentProgressCallback allows for the registration of a callback to track the progress of an individual sent file transfer.

func (*Wrapper) Send

func (w *Wrapper) Send(fileName, fileType string,
	fileData []byte, retry float32, preview []byte,
	progressCB ft.SentProgressCallback, period time.Duration) (
	*ftCrypto.TransferID, error)

Send initiates the sending of a file to the connection partner and returns a transfer ID that uniquely identifies this file transfer. The initial and final messages are sent via connection E2E.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL