packets

package
v0.0.0-...-1c0411e Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2023 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DISC  flags.FlagType = 0b1
	FOUND flags.FlagType = 0b10
	MISS  flags.FlagType = 0b100

	STREAM flags.FlagType = 0b1000
	PORT   flags.FlagType = 0b10000
)
View Source
const (
	WAKE flags.FlagType = 0b1
	CONT flags.FlagType = 0b10
	CSND flags.FlagType = 0b100
	STOP flags.FlagType = 0b1000
	OK   flags.FlagType = 0b10000
	REQ  flags.FlagType = 0b100000
	PING flags.FlagType = 0b1000000
)

Variables

This section is empty.

Functions

func Encode

func Encode[T any](p BasePacket[T]) ([]byte, error)

Types

type BasePacket

type BasePacket[T any] struct {
	Header  PacketHeader
	Payload T
}

func Decode

func Decode[T any](data []byte) (BasePacket[T], error)

func Ok

func Ok() BasePacket[string]

func Ping

func Ping() BasePacket[string]

func Request

func Request(contentName string) BasePacket[string]

func Stop

func Stop(contentName string) BasePacket[string]

func Wake

func Wake() BasePacket[string]
type Header struct {
	Flags     flags.FlagType
	RequestId uuid.UUID
	Source    string
	Hops      uint64
}

type Packet

type Packet struct {
	Header  Header
	Payload Payload
}

func DecodePacket

func DecodePacket(data []byte) (Packet, error)

func Discovery

func Discovery(requestId uuid.UUID, contentName string) Packet

func Found

func Found(requestId uuid.UUID, contentName string, source string) Packet

func Miss

func Miss(requestId uuid.UUID, contentName string) Packet

func Port

func Port(requestId uuid.UUID, contentName string, port string) Packet

func Stream

func Stream(requestId uuid.UUID, contentName string) Packet

func (Packet) Encode

func (p Packet) Encode() ([]byte, error)

type PacketHeader

type PacketHeader struct {
	Flag flags.FlagType
}

type Payload

type Payload struct {
	ContentName string
	Port        string
}

Jump to

Keyboard shortcuts

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