Documentation
¶
Index ¶
- func ChunkSize(payloadSize int64) int64
- type Sender
- func (s *Sender) CloseServer()
- func (s *Sender) ConnectToTranx(tranxAddress string, tranxPort int, passwordCh chan<- models.Password, ...) error
- func (s *Sender) StartServer() error
- func (s *Sender) Transfer(wsConn *websocket.Conn) error
- func (s *Sender) TranxAddress() string
- func (s *Sender) TranxPort() int
- type Server
- type ServerOptions
- type TransferState
- type UIUpdate
- type WrongStateError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Sender ¶
type Sender struct {
// contains filtered or unexported fields
}
Sender represents the sender client, handles tranx communication and file transfer.
func NewSender ¶
func NewSender(programOptions models.TranOptions) *Sender
NewSender returns a bare bones Sender.
func WithPayload ¶
WithPayload specifies the payload that will be transfered.
func WithServer ¶
func WithServer(s *Sender, options ServerOptions) *Sender
WithServer specifies the option to run the sender by hosting a server which the receiver establishes a connection to.
func WithUI ¶
WithUI specifies the option to run the sender with an UI channel that reports the state of the transfer.
func (*Sender) CloseServer ¶
func (s *Sender) CloseServer()
func (*Sender) ConnectToTranx ¶
func (s *Sender) ConnectToTranx( tranxAddress string, tranxPort int, passwordCh chan<- models.Password, startServerCh chan<- ServerOptions, payloadReady <-chan bool, relayCh chan<- *websocket.Conn, ) error
ConnectToTranx, establishes the connection with the tranx server. Paramaters: tranxAddress - IP or hostname of the tranx server tranxPort - port of the tranx server startServerCh - channel to communicate to the caller when to start the server, and with which options. passwordCh - channel to communicate the password to the caller. startServerCh - channel to communicate to the caller when to start the server, and with which options. payloadReady - channel over which the caller can communicate when the payload is ready. relayCh - channel to commuincate if we are using relay (tranx) for transfer.
func (*Sender) StartServer ¶
Start starts the sender.Server webserver and setups graceful shutdown
func (*Sender) TranxAddress ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server specifies the webserver that will be used for direct file transfer.
type ServerOptions ¶
type ServerOptions struct {
// contains filtered or unexported fields
}
Specifies the necessary options for initializing the webserver.
type TransferState ¶
type TransferState int
const ( Initial TransferState = iota WaitForFileRequest SendingData WaitForFileAck WaitForCloseMessage WaitForCloseAck )
func (TransferState) Name ¶
func (s TransferState) Name() string
Name returns the associated to the state enum.
type UIUpdate ¶
type UIUpdate struct { State TransferState Progress float32 }
UIUpdate is a struct that is continously communicated to the UI (if sender has attached a UI)
type WrongStateError ¶
type WrongStateError struct {
// contains filtered or unexported fields
}
WrongStateError is a custom error for the Transfer sequence
func NewWrongStateError ¶
func NewWrongStateError(expected, got TransferState) *WrongStateError
WrongStateError constructor
func (*WrongStateError) Error ¶
func (e *WrongStateError) Error() string