Documentation
¶
Index ¶
- Constants
- func MaxBibStatuses(t transport.Transport, raceAbbrev string) int
- func PackBibStatuses(statuses []*BibStatus, epoch time.Time) []byte
- func ReceiveLoop(t transport.Transport, handle PacketHandler) (err error)
- func SendPacket(t transport.Transport, destAddr transport.Addr, p *ebibv1.EbibPacket) (seq uint32, err error)
- type BibStatus
- type PacketHandler
Constants ¶
const (
BibStatusSize = 5 // size of an encoded bib status
)
Variables ¶
This section is empty.
Functions ¶
func MaxBibStatuses ¶
Returns the maximum number of [BibStatus]es which can fit in a single transmission over the transport.Transport t given the race abbreviation raceAbbrev for this event.
func PackBibStatuses ¶
Encodes a slice of [BibStatus]es into a contiguous buffer for transmission. The epoch time of the race must be given in order to properly encode the timestamp.
func ReceiveLoop ¶
func ReceiveLoop(t transport.Transport, handle PacketHandler) (err error)
ReceiveLoop continuously receives Ebib packets via the transport.Transport t and delivers them to handle for processing. The ebibv1.AckType returned by handle will be sent to the originating station in response, unless handle returns ebibv1.AckType_ACK_TYPE_UNSPECIFIED.
If handle returns a non-nil error, ReceiveLoop will exit, returning that error.
func SendPacket ¶
func SendPacket(t transport.Transport, destAddr transport.Addr, p *ebibv1.EbibPacket) (seq uint32, err error)
Sends the Ebib packet p to the destination destAddr using the transport.Transport t and returns the sequence number assigned to this packet.
If the serialized packet exceeds the MTU of t, then p will automatically be split into a ebibv1.Multipart and sent. In this case, SendPacket will not return until the last multipart segment has been transmitted or an error occurs.
Types ¶
type BibStatus ¶
type BibStatus struct {
// Time this status occurred.
Timestamp time.Time
// Bib ID of the race participant. Does not necessarily match the real bib
// number worn by the participant.
BibId uint16
// Ebib status code.
StatusCode uint8
}
A status update for a race participant.
func DeserializeBibStatus ¶
Decodes a binary bib status update in b into a BibStatus. The epoch time of the race must be given in order to properly decode the timestamp.
func UnpackBibStatuses ¶
Decodes a slice of [BibStatus]es from a contiguous buffer. The epoch time of the race must be given in order to properly decode the timestamp.
type PacketHandler ¶
type PacketHandler func(p *ebibv1.EbibPacket, addr *transport.PacketAddr) (ebibv1.AckType, error)
A PacketHandler is a function which processes a received Ebib packet p. addr contains the packet's address info. It returns an ebibv1.AckType indicating the result of processing.