Documentation ¶
Index ¶
- Constants
- Variables
- func CreatePayloadItems(sp *v1.SessionPayload, dir types.Direction) []*v1.SessionItem
- func FileCount(p *types.Payload) int
- func IsMultiple(p *types.Payload) (bool, error)
- func IsSingle(p *types.Payload) (bool, error)
- func Libp2pID(p *types.Peer) (peer.ID, error)
- func NewInSession(payload *types.Payload, from *types.Peer, to *types.Peer) *v1.Session
- func NewOutSession(payload *types.Payload, to *types.Peer, from *types.Peer) *v1.Session
- func NewSessionPayload(p *types.Payload) *v1.SessionPayload
- func ProgressItem(si *v1.SessionItem, wrt int, n config.CallbackImpl) bool
- func ReadItemFromStream(si *v1.SessionItem, node config.CallbackImpl, reader msgio.ReadCloser) error
- func RouteSessionStream(s *v1.Session, stream network.Stream, n config.CallbackImpl) (*motor.OnTransmitCompleteResponse, error)
- func SessionEvent(s *v1.Session) *motor.OnTransmitCompleteResponse
- func SessionFinalIndex(s *v1.Session) int
- func SessionHasRead(s *v1.Session) bool
- func SessionHasWrote(s *v1.Session) bool
- func SessionIsDone(s *v1.Session) bool
- func SessionIsIn(s *v1.Session) bool
- func SessionIsOut(s *v1.Session) bool
- func URLCount(p *types.Payload) int
- func UpdateCurrent(s *v1.Session, result bool) bool
- func WriteItemToStream(si *v1.SessionItem, node config.CallbackImpl, writer msgio.WriteCloser) error
- type Option
- type PayloadItemFunc
- type TransmitProtocol
- func (p *TransmitProtocol) CurrentSession() (*v1.Session, error)
- func (p *TransmitProtocol) Incoming(payload *types.Payload, from *types.Peer) error
- func (p *TransmitProtocol) Outgoing(payload *types.Payload, to *types.Peer) error
- func (p *TransmitProtocol) Reset(event *motor.OnTransmitCompleteResponse)
Constants ¶
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 ¶
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 IsMultiple ¶ added in v0.18.2
IsMultiple returns true if the transfer is a multiple transfer. Error returned if No Items present in Payload
func IsSingle ¶ added in v0.18.2
IsSingle returns true if the transfer is a single transfer. Error returned if No Items present in Payload
func NewInSession ¶
NewInSession creates a new Session from the given payload with Incoming direction.
func NewOutSession ¶
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 ¶
FinalIndex returns the final index of the session.
func SessionHasRead ¶
HasRead returns true if all files have been read.
func SessionHasWrote ¶
HasWrote returns true if all files have been written.
func SessionIsDone ¶
IsDone returns true if all files have been read or written.
func SessionIsIn ¶
IsIn returns true if the session is incoming.
func SessionIsOut ¶
IsOut returns true if the session is outgoing.
func UpdateCurrent ¶
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 PayloadItemFunc ¶ added in v0.18.2
type PayloadItemFunc func(item *types.Payload_Item, index int, total int) error
** ─────────────────────────────────────────────────────── ** ─── Payload Management ──────────────────────────────── ** ─────────────────────────────────────────────────────── PayloadItemFunc is the Map function for PayloadItem
type TransmitProtocol ¶
type TransmitProtocol struct {
// contains filtered or unexported fields
}
TransmitProtocol type
func New ¶
func New(ctx context.Context, host host.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) Reset ¶
func (p *TransmitProtocol) Reset(event *motor.OnTransmitCompleteResponse)
Reset resets the current session