Documentation ¶
Index ¶
- type ACKPacket
- type DATAPacket
- type Packet
- type PacketType
- type ReceiverState
- type SenderState
- type SequenceID
- type SessionState
- func (state *SessionState) DeliverMessage(transport *TransportLayer, message outboxMessage) SequenceID
- func (state *SessionState) ReceiveACK(transport *TransportLayer, packet *ACKPacket) []*DATAPacket
- func (state *SessionState) ReceiveDATA(transport *TransportLayer, packet *DATAPacket) []*DATAPacket
- type TransportEvents
- type TransportLayer
- func (transport *TransportLayer) AllSessions(contact device.ContactID) []device.SessionID
- func (transport *TransportLayer) BroadcastRouteRequest()
- func (transport *TransportLayer) DeleteContact(contact device.ContactID)
- func (transport *TransportLayer) OnConnection(address device.DeviceAddress)
- func (transport *TransportLayer) OnDisconnection(address device.DeviceAddress)
- func (transport *TransportLayer) ReceivePacket(address device.DeviceAddress, packet []byte) []TransportMessage
- func (transport *TransportLayer) SendMessage(sessionID device.SessionID, message []byte) (device.MessageID, error)
- func (transport *TransportLayer) SessionContact(sessionID device.SessionID) (*device.ContactID, bool)
- func (transport *TransportLayer) SessionState(sessionID device.SessionID) *SessionState
- func (transport *TransportLayer) TimeoutSession(sessionID device.SessionID)
- type TransportMessage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ACKPacket ¶
type ACKPacket struct { LatestSeqID SequenceID MissingSeqIDs []SequenceID }
func DecodeACKPacket ¶
func NewACKPacket ¶
func NewACKPacket(latestSeqID SequenceID, missingSeqIDs []SequenceID) *ACKPacket
func (*ACKPacket) EncodePacket ¶
func (*ACKPacket) PacketType ¶
func (d *ACKPacket) PacketType() PacketType
type DATAPacket ¶
type DATAPacket struct { SeqID SequenceID Data []byte }
func DecodeDataPacket ¶
func DecodeDataPacket(buf []byte) (*DATAPacket, error)
func NewDATAPacket ¶
func NewDATAPacket(seqID SequenceID, data []byte) *DATAPacket
func (*DATAPacket) EncodePacket ¶
func (d *DATAPacket) EncodePacket() []byte
func (*DATAPacket) PacketType ¶
func (d *DATAPacket) PacketType() PacketType
type Packet ¶
type Packet interface { EncodePacket() []byte PacketType() PacketType }
type ReceiverState ¶
type ReceiverState struct {
// contains filtered or unexported fields
}
type SenderState ¶
type SenderState struct {
// contains filtered or unexported fields
}
type SequenceID ¶
type SequenceID uint32
func DecodeSequenceID ¶
func DecodeSequenceID(buf []byte) SequenceID
func (SequenceID) Encode ¶
func (s SequenceID) Encode(buf []byte) []byte
type SessionState ¶
type SessionState struct {
// contains filtered or unexported fields
}
func NewSessionState ¶
func NewSessionState(sessionID device.SessionID) *SessionState
func (*SessionState) DeliverMessage ¶
func (state *SessionState) DeliverMessage(transport *TransportLayer, message outboxMessage) SequenceID
DeliverMessage registers a message as awaiting an ack, it returns the sequence ID for the new packet to be delivered.
func (*SessionState) ReceiveACK ¶
func (state *SessionState) ReceiveACK(transport *TransportLayer, packet *ACKPacket) []*DATAPacket
func (*SessionState) ReceiveDATA ¶
func (state *SessionState) ReceiveDATA(transport *TransportLayer, packet *DATAPacket) []*DATAPacket
Updates the local state with the incoming packet. Returns a list of packets (in ascending sorted order by their sequence ID) that can now be delivered.
type TransportEvents ¶
type TransportEvents interface { SessionEstablished(session device.SessionID, contact device.ContactID, address device.DeviceAddress, payload []byte, isInitiator bool) SessionBroken(session device.SessionID) ReplyPayload(session device.SessionID, contact device.ContactID) []byte MessageDelivered(messageID device.MessageID) }
type TransportLayer ¶
type TransportLayer struct {
// contains filtered or unexported fields
}
func NewTransportLayer ¶
func NewTransportLayer(dev device.Device, events TransportEvents, options device.ProtocolOptions) *TransportLayer
func (*TransportLayer) AllSessions ¶
func (transport *TransportLayer) AllSessions(contact device.ContactID) []device.SessionID
func (*TransportLayer) BroadcastRouteRequest ¶
func (transport *TransportLayer) BroadcastRouteRequest()
func (*TransportLayer) DeleteContact ¶
func (transport *TransportLayer) DeleteContact(contact device.ContactID)
func (*TransportLayer) OnConnection ¶
func (transport *TransportLayer) OnConnection(address device.DeviceAddress)
func (*TransportLayer) OnDisconnection ¶
func (transport *TransportLayer) OnDisconnection(address device.DeviceAddress)
func (*TransportLayer) ReceivePacket ¶
func (transport *TransportLayer) ReceivePacket(address device.DeviceAddress, packet []byte) []TransportMessage
func (*TransportLayer) SendMessage ¶
func (*TransportLayer) SessionContact ¶
func (*TransportLayer) SessionState ¶
func (transport *TransportLayer) SessionState(sessionID device.SessionID) *SessionState
func (*TransportLayer) TimeoutSession ¶
func (transport *TransportLayer) TimeoutSession(sessionID device.SessionID)
Click to show internal directories.
Click to hide internal directories.