server

package
v0.0.0-...-42c7daa Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2025 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ClientBuffer int = 100000
)
View Source
const (
	MaxReadFan int = 3
)
View Source
const (
	MaxSendFan int = 3
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Conn net.Conn
	Fd   int32
	User *entity.User
}

func (*Client) ReadMessage

func (c *Client) ReadMessage(ctx context.Context, epoller *Epoll, logger *slog.Logger) error

func (*Client) SendMessage

func (c *Client) SendMessage(ctx context.Context, msg *valobj.Message) error

type Connections

type Connections map[int32]*Client

type Epoll

type Epoll struct {
	Add    chan net.Conn
	Remove chan *Client
	// contains filtered or unexported fields
}

func NewEpoll

func NewEpoll(pool *Pool, logger *slog.Logger, tracer trace.Tracer) (*Epoll, error)

NewEpoll creates an Epoll

func (*Epoll) Start

func (e *Epoll) Start(ctx context.Context)

Start adds and removes connections from Epoll

func (*Epoll) Wait

func (e *Epoll) Wait() ([]*Client, error)

Wait listens for new epoll events

type EpollEvent

type EpollEvent struct {
	Events []unix.EpollEvent
	Resp   chan []*Client
}

type ErrEpoll

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

func (*ErrEpoll) Error

func (e *ErrEpoll) Error() string

type GameServer

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

func NewGameServer

func NewGameServer(ctx context.Context, ln net.Listener, epoll *Epoll, ngin Startable, pool *Pool, logger *slog.Logger) *GameServer

func (*GameServer) Start

func (gs *GameServer) Start(ctx context.Context)

Start listens for incoming tcp connections

type Pool

type Pool struct {
	Connections Connections

	Register    chan *Client
	Remove      chan int32
	Broadcast   chan *valobj.Event
	Snapshot    chan chan *Snapshot
	EpollEvents chan *EpollEvent
	// contains filtered or unexported fields
}

func NewPool

func NewPool(ctx context.Context, logger *slog.Logger, tracer trace.Tracer) *Pool

func (*Pool) Start

func (p *Pool) Start(ctx context.Context)

type Snapshot

type Snapshot struct {
	Connections Connections
	Processed   chan struct{}
}

type Startable

type Startable interface {
	Start(ctx context.Context)
}

Jump to

Keyboard shortcuts

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