server

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: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContentInfoPacket

func ContentInfoPacket(c []ConfigItem) packets.BasePacket[[]ConfigItem]

func ContentPortPacket

func ContentPortPacket(port string) packets.BasePacket[string]

func Handler

func Handler(conn net.Conn, va ...interface{})

Handler is the function that decides what On* event handler to call.

func Pong

func Pong() packets.BasePacket[string]

func ValidateConfig

func ValidateConfig(obj Config) bool

Types

type Config

type Config struct {
	Content    []ConfigItem `json:"content"`
	Throughput uint         `json:"throughput"`
}

type ConfigItem

type ConfigItem struct {
	Name   string
	Width  uint
	Height uint
	FPS    uint
}

type Server

type Server struct {
	// Address in which the server listen for tcp connections.
	Address netip.AddrPort
	// represents the server properties and what content it has available.
	Config Config

	// tcp listener on the Address
	TCPHandler handlers.TCPConn

	// contains the addresses where I'm streaming to and what content is being streamed
	ConnectionPool streamer.StreamingPool
	// default streamer port, incremented depending on the number of streamers
	AccessPort int
}

func New

func New(addr, path string) *Server

New creates a new server instance when passed its operating address and its configuration file path.

func (*Server) OnContent

func (s *Server) OnContent(conn net.Conn, p packets.BasePacket[string])

OnContent handles the request 'REQ' from the client. First the server responds via TCP (conn net.Conn) with the port where the content will be streamed on. Once the client answers with an 'OK' packet then we start the UDP stream by utilizing our streamer.Streamer struct.

func (*Server) OnPing

func (s *Server) OnPing(conn net.Conn)

OnPing function answers with Pong to Ping requests, used in metrics measurements by the clients, such as latency, jitter and packet loss.

func (*Server) OnStop

func (s *Server) OnStop(conn net.Conn, p packets.BasePacket[string])

OnStop function is responsible for stopping the transmission of a certain content. With every connection (alongside its streaming connections) being stored in a StreamingPool we can assure that we can stop its streaming goroutines.

func (*Server) OnWake

func (s *Server) OnWake(conn net.Conn)

OnWake handles the request 'WAKE' from the client (rendezvous point). Once this kind of request arrives, the server will answer with a list of ConfigItem representing what content it can stream.

func (*Server) Run

func (s *Server) Run()

Run function is responsible for running the main loop of the server.

Jump to

Keyboard shortcuts

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