kcp

package
v0.0.0-...-5462533 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	IHandler xnetcommon.IHandler
	IRemote  xnetcommon.IRemote
}

Client 客户端

func NewClient

func NewClient(handler xnetcommon.IHandler) *Client

func (*Client) Connect

func (p *Client) Connect(ctx context.Context, opts ...*ClientOptions) error

Connect 连接

type ClientOptions

type ClientOptions struct {
	HeaderStrategy xpacket.IHeaderStrategy
	xnetcommon.ConnOptions
	xnetcommon.KCPOptions
	// contains filtered or unexported fields
}

ClientOptions contains options to configure a Server instance. Each option can be set through setter functions. See documentation for each setter function for an explanation of the option.

func NewClientOptions

func NewClientOptions() *ClientOptions

NewClientOptions 新的ClientOptions

func (*ClientOptions) WithAddress

func (p *ClientOptions) WithAddress(address string) *ClientOptions

func (*ClientOptions) WithHeaderStrategy

func (p *ClientOptions) WithHeaderStrategy(strategy xpacket.IHeaderStrategy) *ClientOptions

func (*ClientOptions) WithIOut

func (p *ClientOptions) WithIOut(iOut xcontrol.IOut) *ClientOptions

func (*ClientOptions) WithSendChanCapacity

func (p *ClientOptions) WithSendChanCapacity(sendChanCapacity uint32) *ClientOptions

type Remote

type Remote struct {
	UDPSession *kcp.UDPSession
	*xnetcommon.DefaultRemote
}

Remote 远端信息

func NewRemote

func NewRemote(udpSession *kcp.UDPSession, sendChan chan interface{}, headerStrategy xpacket.IHeaderStrategy) *Remote

func (*Remote) GetIP

func (p *Remote) GetIP() string

GetIP 获取IP地址

func (*Remote) IsConnect

func (p *Remote) IsConnect() bool

IsConnect 是否连接

func (*Remote) Send

func (p *Remote) Send(packet xpacket.IPacket) error

Send 发送数据

[⚠️]必须在 总线/actor 中调用
参数:
	packet: 未序列化的包. [NOTE]该数据会被引用,使用层不可写

func (*Remote) Start

func (p *Remote) Start(connOptions *xnetcommon.ConnOptions, iout xcontrol.IOut, handler xnetcommon.IHandler)

开始

func (*Remote) Stop

func (p *Remote) Stop()

Stop 停止

type Server

type Server struct {
	IHandler xnetcommon.IHandler
	// contains filtered or unexported fields
}

Server 服务端

func NewServer

func NewServer(handler xnetcommon.IHandler) *Server

NewServer 新建服务

func (*Server) Start

func (p *Server) Start(_ context.Context, opts ...*ServerOptions) error

Start 开始

func (*Server) Stop

func (p *Server) Stop()

Stop 停止 AcceptTCP

type ServerOptions

type ServerOptions struct {
	HeaderStrategy xpacket.IHeaderStrategy
	xnetcommon.ConnOptions
	xnetcommon.KCPOptions
	xnetcommon.PacketLimitOptions
	// contains filtered or unexported fields
}

ServerOptions contains options to serverConfigure a Server instance. Each option can be set through setter functions. See documentation for each setter function for an explanation of the option.

func NewOptions

func NewOptions() *ServerOptions

NewOptions 新的Options

func (*ServerOptions) WithHeaderStrategy

func (p *ServerOptions) WithHeaderStrategy(strategy xpacket.IHeaderStrategy) *ServerOptions

func (*ServerOptions) WithIOut

func (p *ServerOptions) WithIOut(iOut xcontrol.IOut) *ServerOptions

func (*ServerOptions) WithIsActor

func (p *ServerOptions) WithIsActor(isActor bool) *ServerOptions

func (*ServerOptions) WithListenAddress

func (p *ServerOptions) WithListenAddress(listenAddress string) *ServerOptions

func (*ServerOptions) WithSendChanCapacity

func (p *ServerOptions) WithSendChanCapacity(sendChanCapacity uint32) *ServerOptions

Jump to

Keyboard shortcuts

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