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 { ...@@ -268,9 +268,11 @@ func (f *FileTransfer) CloseSend(tidBytes []byte) error {
// Parameters: // Parameters:
// - tidBytes - file transfer ID // - tidBytes - file transfer ID
// - callback - callback that reports file reception progress // - 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, func (f *FileTransfer) RegisterSentProgressCallback(tidBytes []byte,
callback FileTransferSentProgressCallback, period string) error { callback FileTransferSentProgressCallback, period int) error {
cb := func(completed bool, arrived, total uint16, cb := func(completed bool, arrived, total uint16,
st fileTransfer.SentTransfer, t fileTransfer.FilePartTracker, err error) { st fileTransfer.SentTransfer, t fileTransfer.FilePartTracker, err error) {
prog := &Progress{ prog := &Progress{
...@@ -282,10 +284,7 @@ func (f *FileTransfer) RegisterSentProgressCallback(tidBytes []byte, ...@@ -282,10 +284,7 @@ func (f *FileTransfer) RegisterSentProgressCallback(tidBytes []byte,
pm, err := json.Marshal(prog) pm, err := json.Marshal(prog)
callback.Callback(pm, &FilePartTracker{t}, err) callback.Callback(pm, &FilePartTracker{t}, err)
} }
p, err := time.ParseDuration(period) p := time.Millisecond * time.Duration(period)
if err != nil {
return err
}
tid := ftCrypto.UnmarshalTransferID(tidBytes) tid := ftCrypto.UnmarshalTransferID(tidBytes)
return f.w.RegisterSentProgressCallback(&tid, cb, p) return f.w.RegisterSentProgressCallback(&tid, cb, p)
...@@ -299,9 +298,11 @@ func (f *FileTransfer) RegisterSentProgressCallback(tidBytes []byte, ...@@ -299,9 +298,11 @@ func (f *FileTransfer) RegisterSentProgressCallback(tidBytes []byte,
// Parameters: // Parameters:
// - tidBytes - file transfer ID // - tidBytes - file transfer ID
// - callback - callback that reports file reception progress // - 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, func (f *FileTransfer) RegisterReceivedProgressCallback(tidBytes []byte,
callback FileTransferReceiveProgressCallback, period string) error { callback FileTransferReceiveProgressCallback, period int) error {
cb := func(completed bool, received, total uint16, cb := func(completed bool, received, total uint16,
rt fileTransfer.ReceivedTransfer, t fileTransfer.FilePartTracker, err error) { rt fileTransfer.ReceivedTransfer, t fileTransfer.FilePartTracker, err error) {
prog := &Progress{ prog := &Progress{
...@@ -313,10 +314,8 @@ func (f *FileTransfer) RegisterReceivedProgressCallback(tidBytes []byte, ...@@ -313,10 +314,8 @@ func (f *FileTransfer) RegisterReceivedProgressCallback(tidBytes []byte,
pm, err := json.Marshal(prog) pm, err := json.Marshal(prog)
callback.Callback(pm, &FilePartTracker{t}, err) callback.Callback(pm, &FilePartTracker{t}, err)
} }
p, err := time.ParseDuration(period) p := time.Millisecond * time.Duration(period)
if err != nil {
return err
}
tid := ftCrypto.UnmarshalTransferID(tidBytes) tid := ftCrypto.UnmarshalTransferID(tidBytes)
return f.w.RegisterReceivedProgressCallback(&tid, cb, p) 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