kcp

package
v0.0.0-...-6785f5e Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Remote

type Remote struct {
	UDPSession *kcp.UDPSession

	Object           interface{}                 // 保存 应用层数据
	DisconnectReason xnetcommon.DisconnectReason // 断开原因
	// contains filtered or unexported fields
}

Remote 远端信息

func NewRemote

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

func (*Remote) GetDisconnectReason

func (p *Remote) GetDisconnectReason() xnetcommon.DisconnectReason

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 发送数据

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

func (*Remote) SetDisconnectReason

func (p *Remote) SetDisconnectReason(reason xnetcommon.DisconnectReason)

func (*Remote) Start

func (p *Remote) Start(connOptions *xnetcommon.ConnOptions, event xnetcommon.IEvent, handler xnetcommon.IHandler)

开始

func (*Remote) Stop

func (p *Remote) Stop()

Stop 停止

type Server

type Server struct {
	IEvent   xnetcommon.IEvent
	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 {
	// 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. TODO 修改源码中 minrto 为10ms

func NewOptions

func NewOptions() *ServerOptions

NewOptions 新的Options

func (*ServerOptions) WithAckNoDelay

func (p *ServerOptions) WithAckNoDelay(ackNoDelay bool) *ServerOptions

func (*ServerOptions) WithBlockCrypt

func (p *ServerOptions) WithBlockCrypt(blockCrypt kcp.BlockCrypt) *ServerOptions

func (*ServerOptions) WithEventChan

func (p *ServerOptions) WithEventChan(eventChan chan<- interface{}) *ServerOptions

func (*ServerOptions) WithFEC

func (p *ServerOptions) WithFEC(fec bool) *ServerOptions

func (*ServerOptions) WithListenAddress

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

func (*ServerOptions) WithMTUBytes

func (p *ServerOptions) WithMTUBytes(size int) *ServerOptions

func (*ServerOptions) WithReadBuffer

func (p *ServerOptions) WithReadBuffer(readBuffer int) *ServerOptions

func (*ServerOptions) WithSendChanCapacity

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

func (*ServerOptions) WithWindowSize

func (p *ServerOptions) WithWindowSize(size int) *ServerOptions

func (*ServerOptions) WithWriteBuffer

func (p *ServerOptions) WithWriteBuffer(writeBuffer int) *ServerOptions

Jump to

Keyboard shortcuts

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