Skip to content

Commit

Permalink
add receiver main struct and functions in core/receiver pkg
Browse files Browse the repository at this point in the history
  • Loading branch information
abdfnx committed Feb 4, 2022
1 parent fc46c41 commit c407ad0
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions core/receiver/receiver.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package receiver

import (
"github.com/abdfnx/tran/models"
"github.com/abdfnx/tran/core/crypt"
)

type Receiver struct {
crypt *crypt.Crypt
payloadSize int64
tranxAddress string
tranxPort int
ui chan<- UIUpdate
usedRelay bool
}

func NewReceiver(programOptions models.TranOptions) *Receiver {
return &Receiver{
tranxAddress: programOptions.TranxAddress,
tranxPort: programOptions.TranxPort,
}
}

func WithUI(r *Receiver, ui chan<- UIUpdate) *Receiver {
r.ui = ui
return r
}

func (r *Receiver) UsedRelay() bool {
return r.usedRelay
}

func (r *Receiver) PayloadSize() int64 {
return r.payloadSize
}

func (r *Receiver) TranxAddress() string {
return r.tranxAddress
}

func (r *Receiver) TranxPort() int {
return r.tranxPort
}

func (r *Receiver) updateUI(progress float32) {
if r.ui == nil {
return
}

r.ui <- UIUpdate{Progress: progress}
}

0 comments on commit c407ad0

Please sign in to comment.