transport_udp

package
v0.0.0-...-da72ffe Latest Latest
Warning

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

Go to latest
Published: May 16, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

type Server struct {
	*gnet.EventServer
	// contains filtered or unexported fields
}

Server struct represents the UDP server using gnet

func NewServer

func NewServer(ctx context.Context, cnf config.UdpTransport) (*Server, error)

NewServer creates a new UDP Server instance using the provided configuration

func (*Server) Addr

func (s *Server) Addr() string

Addr returns the UDP address as a string

func (*Server) DeregisterHandler

func (s *Server) DeregisterHandler(actionType types.HandlerType)

DeregisterHandler deregisters a handler for a specific action

func (*Server) OnInitComplete

func (s *Server) OnInitComplete(server gnet.Server) (action gnet.Action)

OnInitComplete is called when the server starts

func (*Server) React

func (s *Server) React(frame []byte, c gnet.Conn) (out []byte, action gnet.Action)

React handles incoming data

func (*Server) RegisterHandler

func (s *Server) RegisterHandler(actionType types.HandlerType, handler UDPHandler)

RegisterHandler registers a handler for a specific action

func (*Server) Start

func (s *Server) Start(ctx context.Context) error

Start starts the UDP server using the provided configuration

func (*Server) Stop

func (s *Server) Stop() error

Stop stops the UDP server

func (*Server) Tick

func (s *Server) Tick() (delay time.Duration, action gnet.Action)

Tick is called periodically by gnet

func (*Server) WaitStarted

func (s *Server) WaitStarted() <-chan struct{}

WaitStarted returns the started channel for waiting until the server starts

type UDPHandler

type UDPHandler func(c gnet.Conn, frame []byte)

UDPHandler function type for UDP handlers

type UDPReadHandler

type UDPReadHandler struct {
	// contains filtered or unexported fields
}

UDPReadHandler struct with MDBX database passed in

func NewUDPReadHandler

func NewUDPReadHandler(db db.Provider) *UDPReadHandler

NewUDPReadHandler creates a new UDPReadHandler with an MDBX database

func (*UDPReadHandler) HandleMessage

func (rh *UDPReadHandler) HandleMessage(c gnet.Conn, frame []byte)

HandleMessage processes the incoming message using the UDPReadHandler

type UDPWriteHandler

type UDPWriteHandler struct {
	// contains filtered or unexported fields
}

UDPWriteHandler struct with MDBX database passed in

func NewUDPWriteHandler

func NewUDPWriteHandler(db db.Provider, batchWriter *db.BatchWriter) *UDPWriteHandler

NewUDPWriteHandler creates a new UDPWriteHandler with an MDBX database

func (*UDPWriteHandler) HandleMessage

func (wh *UDPWriteHandler) HandleMessage(c gnet.Conn, frame []byte)

HandleMessage processes the incoming message using the UDPWriteHandler

Jump to

Keyboard shortcuts

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