Net

package
v0.0.0-...-348a65b Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2024 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Overview

好用的kcp 爱 来自 hk4e-go

Index

Constants

View Source
const (
	PacketMaxLen            = 343 * 1024 // 最大应用层包长度
	KcpConnAddrChangeNotify = "KcpConnAddrChangeNotify"
)

Variables

View Source
var CLIENT_CONN_NUM int32 = 0 // 当前客户端连接数

Functions

func Close

func Close() error

func DecodeBinToPayload

func DecodeBinToPayload(data []byte, kcpMsgList *[]*KcpMsg, xorKey []byte)

func DecodeGmPayloadToProto

func DecodeGmPayloadToProto(g *Game.Game, msg *GmMsg) (protoObj pb.Message)

func DecodeLoop

func DecodeLoop(data []byte, kcpMsgList *[]*KcpMsg)

func DecodePayloadToProto

func DecodePayloadToProto(g *Game.Game, msg *KcpMsg) (protoObj pb.Message)

TODO 由于 req 大部分缺失,所以不预处理数据

func EncodePayloadToBin

func EncodePayloadToBin(kcpMsg *KcpMsg, xorKey []byte) (bin []byte)

func GmToGs

func GmToGs(uid uint32, gmMsg *GmMsg) bool

func HandlePlayerGetTokenCsReq

func HandlePlayerGetTokenCsReq(g *Game.Game, payloadMsg []byte)

func NewGame

func NewGame(kcpConn *kcp.UDPSession) *Game.Game

func Run

func Run() error

Types

type GmMsg

type GmMsg struct {
	CmdId     uint16
	ProtoData []byte
}

type KcpConnManager

type KcpConnManager struct {
	// contains filtered or unexported fields
}
var KCPCONNMANAGER *KcpConnManager

func (*KcpConnManager) SendHandle

func (k *KcpConnManager) SendHandle(g *Game.Game, cmdid uint16, playerMsg pb.Message)

发送事件处理

type KcpEvent

type KcpEvent struct {
	SessionId    uint32
	EventId      string
	EventMessage any
}

type KcpMsg

type KcpMsg struct {
	CmdId     uint16
	HeadData  []byte
	ProtoData []byte
}

func EncodeProtoToPayload

func EncodeProtoToPayload(protoMsg *ProtoMsg) (kcpMsg *KcpMsg)

type ProtoMessage

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

type ProtoMsg

type ProtoMsg struct {
	CmdId          uint16
	PayloadMessage pb.Message
}

Jump to

Keyboard shortcuts

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