gate

package
v0.0.0-...-bfc2f26 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 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 ClientCodec

type ClientCodec struct {
	RingBufferCodec

	// 在proto序列化后的数据,再做一层编码
	// encoder after proto.Message serialize
	ProtoPacketBytesEncoder func(protoPacketBytes [][]byte) [][]byte

	// 在proto反序列化之前,先做一层解码
	// decoder before proto.Message deserialize
	ProtoPacketBytesDecoder func(packetData []byte) []byte

	// 消息号和proto.Message type的映射表
	MessageCreatorMap map[PacketCommand]reflect.Type
}

Tcp客户端和gate之间的编解码

func NewClientCodec

func NewClientCodec() *ClientCodec

func (*ClientCodec) DecodePacket

func (this *ClientCodec) DecodePacket(connection Connection, packetHeader PacketHeader, packetData []byte) Packet

func (*ClientCodec) EncodePacket

func (this *ClientCodec) EncodePacket(connection Connection, packet Packet) [][]byte

func (*ClientCodec) Register

func (this *ClientCodec) Register(command PacketCommand, protoMessage proto.Message)

注册消息和proto.Message的映射

protoMessage can be nil

type ClientConnectionHandler

type ClientConnectionHandler struct {
	DefaultConnectionHandler
}

客户端连接的handler

func NewClientConnectionHandler

func NewClientConnectionHandler(protoCodec Codec) *ClientConnectionHandler

type ClientData

type ClientData struct {
	ConnId       uint32
	AccountId    int64
	PlayerId     int64
	GameServerId int32
}

客户端绑定数据

type ClientListerHandler

type ClientListerHandler struct {
}

客户端listener handler

func (*ClientListerHandler) OnConnectionConnected

func (this *ClientListerHandler) OnConnectionConnected(listener Listener, acceptedConnection Connection)

func (*ClientListerHandler) OnConnectionDisconnect

func (this *ClientListerHandler) OnConnectionDisconnect(listener Listener, connection Connection)

客户端断开连接

type GateServer

type GateServer struct {
	BaseServer
	// contains filtered or unexported fields
}

func (*GateServer) Init

func (this *GateServer) Init(ctx context.Context, configFile string) bool

初始化

type GateServerConfig

type GateServerConfig struct {
	BaseServerConfig
	// WebSocket测试
	WsClientListenAddr     string
	WsClientListenerConfig ListenerConfig
}

gate服配置

type WsClientCodec

type WsClientCodec struct {
	SimpleProtoCodec
}

WebSocket客户端和gate之间的编解码

func NewWsClientCodec

func NewWsClientCodec() *WsClientCodec

func (*WsClientCodec) Decode

func (this *WsClientCodec) Decode(connection Connection, data []byte) (newPacket Packet, err error)

Jump to

Keyboard shortcuts

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