transmit

package
v0.15.1 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2022 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FilePID       protocol.ID = "/transmit/file/0.0.1"
	DonePID       protocol.ID = "/transmit/done/0.0.1"
	ITEM_INTERVAL             = 25
)

Transfer Protocol ID's

Variables

View Source
var (
	ErrNoSession        = errors.New("Failed to get current session, set to nil")
	ErrFailedAuth       = errors.New("Failed to Authenticate message")
	ErrInvalidDirection = errors.New("Direction was not set")
)

Error Definitions

Functions

func CreatePayloadItems

func CreatePayloadItems(sp *v1.SessionPayload, dir types.Direction) []*v1.SessionItem

CreateItems creates list of sessionItems

func NewInSession

func NewInSession(payload *types.Payload, from *types.Peer, to *types.Peer) *v1.Session

NewInSession creates a new Session from the given payload with Incoming direction.

func NewOutSession

func NewOutSession(payload *types.Payload, to *types.Peer, from *types.Peer) *v1.Session

NewOutSession creates a new Session from the given payload with Outgoing direction.

func NewSessionPayload

func NewSessionPayload(p *types.Payload) *v1.SessionPayload

NewSessionPayload creates session payload

func ProgressItem

func ProgressItem(si *v1.SessionItem, wrt int, n config.CallbackImpl) bool

Progress pushes a progress event to the node. Returns true if the item is done.

func ReadItemFromStream

func ReadItemFromStream(si *v1.SessionItem, node config.CallbackImpl, reader msgio.ReadCloser) error

ReadFromStream reads the item from the stream

func RouteSessionStream

func RouteSessionStream(s *v1.Session, stream network.Stream, n config.CallbackImpl) (*motor.OnTransmitCompleteResponse, error)

RouteStream is used to route the given stream to the given peer.

func SessionEvent

func SessionEvent(s *v1.Session) *motor.OnTransmitCompleteResponse

Event returns the complete event for the session.

func SessionFinalIndex

func SessionFinalIndex(s *v1.Session) int

FinalIndex returns the final index of the session.

func SessionHasRead

func SessionHasRead(s *v1.Session) bool

HasRead returns true if all files have been read.

func SessionHasWrote

func SessionHasWrote(s *v1.Session) bool

HasWrote returns true if all files have been written.

func SessionIsDone

func SessionIsDone(s *v1.Session) bool

IsDone returns true if all files have been read or written.

func SessionIsIn

func SessionIsIn(s *v1.Session) bool

IsIn returns true if the session is incoming.

func SessionIsOut

func SessionIsOut(s *v1.Session) bool

IsOut returns true if the session is outgoing.

func UpdateCurrent

func UpdateCurrent(s *v1.Session, result bool) bool

UpdateCurrent updates the current index of the session.

func WriteItemToStream

func WriteItemToStream(si *v1.SessionItem, node config.CallbackImpl, writer msgio.WriteCloser) error

WriteToStream writes the item to the stream

Types

type Option

type Option func(*options)

Option is a function that can be applied to ExchangeProtocol config

type TransmitProtocol

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

TransmitProtocol type

func New

func New(ctx context.Context, node node.HostImpl, cb config.CallbackImpl, options ...Option) (*TransmitProtocol, error)

New creates a new TransferProtocol

func (*TransmitProtocol) CurrentSession

func (p *TransmitProtocol) CurrentSession() (*v1.Session, error)

CurrentSession returns the current session

func (*TransmitProtocol) Incoming

func (p *TransmitProtocol) Incoming(payload *types.Payload, from *types.Peer) error

Incoming is called by the node to accept an incoming transfer

func (*TransmitProtocol) Outgoing

func (p *TransmitProtocol) Outgoing(payload *types.Payload, to *types.Peer) error

Outgoing is called by the node to initiate a transfer

func (*TransmitProtocol) Reset

Reset resets the current session

Jump to

Keyboard shortcuts

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