internal

package
v0.0.29 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NetTypeTCP = iota
	NetTypeWebSocket
	NetTypeKCP
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseClient added in v0.0.25

type BaseClient struct {
	*client.Options

	Id int64
	// contains filtered or unexported fields
}

func NewBaseClient added in v0.0.25

func NewBaseClient(id int64, handshakePack client.HandshakePackFunc, dialer Dialer, options *client.Options) *BaseClient

func (*BaseClient) DefaultDialog added in v0.0.27

func (c *BaseClient) DefaultDialog() (xnet.ClientDialog, bool)

func (*BaseClient) Dialog added in v0.0.27

func (c *BaseClient) Dialog(dialogID uint64) (xnet.ClientDialog, bool)

func (*BaseClient) Start added in v0.0.25

func (c *BaseClient) Start(ctx context.Context) (err error)

func (*BaseClient) Stop added in v0.0.25

func (c *BaseClient) Stop(ctx context.Context) (err error)

func (*BaseClient) Target added in v0.0.25

func (c *BaseClient) Target() string

func (*BaseClient) WalkDialogs added in v0.0.26

func (c *BaseClient) WalkDialogs(fn func(dialog xnet.ClientDialog))

type BaseServer added in v0.0.25

type BaseServer struct {
	xsync.Stoppable
	*server.Options
	// contains filtered or unexported fields
}

func NewBaseServer added in v0.0.25

func NewBaseServer(listener Listener, svc xnet.Service, options *server.Options) (*BaseServer, error)

func (*BaseServer) Broadcast added in v0.0.25

func (s *BaseServer) Broadcast(ctx context.Context, color string, sid int64, pack xnet.Pack) (err error)

func (*BaseServer) Disconnect added in v0.0.25

func (s *BaseServer) Disconnect(ctx context.Context, wid uint64) error

func (*BaseServer) Endpoint added in v0.0.25

func (s *BaseServer) Endpoint() (*url.URL, error)

func (*BaseServer) Multicast added in v0.0.25

func (s *BaseServer) Multicast(ctx context.Context, uids []int64, pack xnet.Pack) (err error)

func (*BaseServer) Push added in v0.0.25

func (s *BaseServer) Push(ctx context.Context, uid int64, pack xnet.Pack) error

func (*BaseServer) Start added in v0.0.25

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

func (*BaseServer) Stop added in v0.0.25

func (s *BaseServer) Stop(ctx context.Context) (err error)

func (*BaseServer) WIDList added in v0.0.25

func (s *BaseServer) WIDList() []uint64

type ConnCarrier added in v0.0.28

type ConnCarrier struct {
	ID    uint64
	Conn  net.Conn
	Codec xnet.Codec
}

func NewConnCarrier added in v0.0.28

func NewConnCarrier(id uint64, conn net.Conn, codec xnet.Codec) ConnCarrier

func (ConnCarrier) Close added in v0.0.28

func (c ConnCarrier) Close() error

type ConnIDGenerator added in v0.0.26

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

func NewConnIDGenerator added in v0.0.26

func NewConnIDGenerator(netType int) *ConnIDGenerator

func (*ConnIDGenerator) Next added in v0.0.26

func (g *ConnIDGenerator) Next() uint64

type CreateTunnelFunc

type CreateTunnelFunc func(ctx context.Context, tunnelType int32, objectId int64) (xnet.Tunnel, error)

type Dialer added in v0.0.25

type Dialer interface {
	// Dial establishes a connection to the target
	Dial(ctx context.Context, target string) (conns []ConnCarrier, err error)

	// Stop stops the dialer
	Stop(ctx context.Context) error

	// Target returns the target address/URL for this dialer
	Target() string
}

Dialer defines the interface for protocol-specific connection dialing

type Dialog added in v0.0.26

type Dialog struct {
	xsync.Stoppable
	// contains filtered or unexported fields
}

func (*Dialog) ID added in v0.0.26

func (d *Dialog) ID() uint64

func (*Dialog) Receive added in v0.0.26

func (d *Dialog) Receive() <-chan xnet.Pack

func (*Dialog) Send added in v0.0.26

func (d *Dialog) Send(pack xnet.Pack) (err error)

func (*Dialog) WaitAuthed added in v0.0.26

func (d *Dialog) WaitAuthed()

type Listener added in v0.0.25

type Listener interface {
	// Start starts the listener and begins accepting connections
	Start(ctx context.Context) error

	// Stop stops the listener gracefully
	Stop(ctx context.Context) error

	// Accept accepts a new connection and returns it as net.Conn
	Accept(ctx context.Context) (ConnCarrier, error)

	// Endpoint returns the endpoint URL for this listener
	Endpoint() (string, error)
}

Listener defines the interface for protocol-specific connection handling

type Tunnel added in v0.0.25

type Tunnel struct {
	xsync.Stoppable
	xnet.AppTunnel
	// contains filtered or unexported fields
}

func (*Tunnel) Forward added in v0.0.25

func (t *Tunnel) Forward(ctx context.Context, p xnet.TunnelMessage) error

type Worker

type Worker struct {
	xsync.Stoppable
	// contains filtered or unexported fields
}

func (*Worker) Color

func (w *Worker) Color() string

func (*Worker) Conn

func (w *Worker) Conn() net.Conn

func (*Worker) Connected added in v0.0.15

func (w *Worker) Connected() bool

func (*Worker) Endpoint

func (w *Worker) Endpoint() string

func (*Worker) Push

func (w *Worker) Push(ctx context.Context, out xnet.Pack) error

func (*Worker) Run

func (w *Worker) Run(ctx context.Context) error

func (*Worker) SID

func (w *Worker) SID() int64

func (*Worker) Session

func (w *Worker) Session() xnet.Session

func (*Worker) Start

func (w *Worker) Start(ctx context.Context) (err error)

func (*Worker) Status

func (w *Worker) Status() int64

func (*Worker) Stop

func (w *Worker) Stop(ctx context.Context) (err error)

func (*Worker) Tunnel

func (w *Worker) Tunnel(ctx context.Context, mod int32, oid int64) (t xnet.Tunnel, err error)

func (*Worker) UID

func (w *Worker) UID() int64

func (*Worker) WID

func (w *Worker) WID() uint64

type WorkerManager added in v0.0.7

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

func (*WorkerManager) Del added in v0.0.7

func (m *WorkerManager) Del(wid uint64)

func (*WorkerManager) GetByUID added in v0.0.7

func (m *WorkerManager) GetByUID(uid int64) *Worker

func (*WorkerManager) GetByUIDs added in v0.0.7

func (m *WorkerManager) GetByUIDs(uids []int64) map[int64]*Worker

func (*WorkerManager) Put added in v0.0.7

func (m *WorkerManager) Put(w *Worker) (old *Worker)

func (*WorkerManager) Walk added in v0.0.7

func (m *WorkerManager) Walk(f func(w *Worker) bool)

func (*WorkerManager) Worker added in v0.0.7

func (m *WorkerManager) Worker(wid uint64) *Worker

Directories

Path Synopsis
Package ip provides utilities for IP address operations, including detection of internal IPs, extracting addresses from connections, and client IP identification in request contexts.
Package ip provides utilities for IP address operations, including detection of internal IPs, extracting addresses from connections, and client IP identification in request contexts.

Jump to

Keyboard shortcuts

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