Skip to content
Snippets Groups Projects
Commit aed5d95a authored by Jake Taylor's avatar Jake Taylor :lips:
Browse files

Merge branch 'xx-4189/period-docs' into 'release'

Improve comments to specify how period is formatted

See merge request !376
parents b6705445 7f90d79e
No related branches found
No related tags found
2 merge requests!510Release,!376Improve comments to specify how period is formatted
......@@ -268,9 +268,11 @@ func (f *FileTransfer) CloseSend(tidBytes []byte) error {
// Parameters:
// - tidBytes - file transfer ID
// - callback - callback that reports file reception progress
// - period - duration to wait between progress callbacks triggering
// - period - Duration (in ms) to wait between progress callbacks triggering.
// This value should depend on how frequently you want to receive
// updates, and should be tuned to your implementation.
func (f *FileTransfer) RegisterSentProgressCallback(tidBytes []byte,
callback FileTransferSentProgressCallback, period string) error {
callback FileTransferSentProgressCallback, period int) error {
cb := func(completed bool, arrived, total uint16,
st fileTransfer.SentTransfer, t fileTransfer.FilePartTracker, err error) {
prog := &Progress{
......@@ -282,10 +284,7 @@ func (f *FileTransfer) RegisterSentProgressCallback(tidBytes []byte,
pm, err := json.Marshal(prog)
callback.Callback(pm, &FilePartTracker{t}, err)
}
p, err := time.ParseDuration(period)
if err != nil {
return err
}
p := time.Millisecond * time.Duration(period)
tid := ftCrypto.UnmarshalTransferID(tidBytes)
return f.w.RegisterSentProgressCallback(&tid, cb, p)
......@@ -299,9 +298,11 @@ func (f *FileTransfer) RegisterSentProgressCallback(tidBytes []byte,
// Parameters:
// - tidBytes - file transfer ID
// - callback - callback that reports file reception progress
// - period - duration to wait between progress callbacks triggering
// - period - Duration (in ms) to wait between progress callbacks triggering.
// This value should depend on how frequently you want to receive
// updates, and should be tuned to your implementation.
func (f *FileTransfer) RegisterReceivedProgressCallback(tidBytes []byte,
callback FileTransferReceiveProgressCallback, period string) error {
callback FileTransferReceiveProgressCallback, period int) error {
cb := func(completed bool, received, total uint16,
rt fileTransfer.ReceivedTransfer, t fileTransfer.FilePartTracker, err error) {
prog := &Progress{
......@@ -313,10 +314,8 @@ func (f *FileTransfer) RegisterReceivedProgressCallback(tidBytes []byte,
pm, err := json.Marshal(prog)
callback.Callback(pm, &FilePartTracker{t}, err)
}
p, err := time.ParseDuration(period)
if err != nil {
return err
}
p := time.Millisecond * time.Duration(period)
tid := ftCrypto.UnmarshalTransferID(tidBytes)
return f.w.RegisterReceivedProgressCallback(&tid, cb, p)
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment