processor

package
v1.18.3 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2022 License: Apache-2.0 Imports: 7 Imported by: 2

Documentation

Index

Constants

View Source
const MsgTypeSize = 2
View Source
const RawMsgTypeSize = 2

Variables

This section is empty.

Functions

This section is empty.

Types

type ConnectHandler

type ConnectHandler func(clientId uint64)

type ConnectJsonHandler

type ConnectJsonHandler func(clientId uint64)

type IProcessor

type IProcessor interface {
	// must goroutine safe
	MsgRoute(clientId uint64, msg interface{}) error
	//must goroutine safe
	UnknownMsgRoute(clientId uint64, msg interface{})
	// connect event
	ConnectedRoute(clientId uint64)
	DisConnectedRoute(clientId uint64)

	// must goroutine safe
	Unmarshal(clientId uint64, data []byte) (interface{}, error)
	// must goroutine safe
	Marshal(clientId uint64, msg interface{}) ([]byte, error)
}

type IRawProcessor

type IRawProcessor interface {
	SetByteOrder(littleEndian bool)
	MsgRoute(clientId uint64, msg interface{}) error
	Unmarshal(clientId uint64, data []byte) (interface{}, error)
	Marshal(clientId uint64, msg interface{}) ([]byte, error)

	SetRawMsgHandler(handle RawMessageHandler)
	MakeRawMsg(msgType uint16, msg []byte, pbRawPackInfo *PBRawPackInfo)
	UnknownMsgRoute(clientId uint64, msg interface{})
	ConnectedRoute(clientId uint64)
	DisConnectedRoute(clientId uint64)

	SetUnknownMsgHandler(unknownMessageHandler UnknownRawMessageHandler)
	SetConnectedHandler(connectHandler RawConnectHandler)
	SetDisConnectedHandler(disconnectHandler RawConnectHandler)
}

type JsonPackInfo

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

func (*JsonPackInfo) GetMsg

func (slf *JsonPackInfo) GetMsg() interface{}

func (*JsonPackInfo) GetPackType

func (slf *JsonPackInfo) GetPackType() uint16

type JsonProcessor

type JsonProcessor struct {
	LittleEndian bool

	network.INetMempool
	// contains filtered or unexported fields
}

func NewJsonProcessor

func NewJsonProcessor() *JsonProcessor

func (*JsonProcessor) ConnectedRoute

func (jsonProcessor *JsonProcessor) ConnectedRoute(clientId uint64)

func (*JsonProcessor) DisConnectedRoute

func (jsonProcessor *JsonProcessor) DisConnectedRoute(clientId uint64)

func (*JsonProcessor) MakeMsg

func (jsonProcessor *JsonProcessor) MakeMsg(msgType uint16, msg interface{}) *JsonPackInfo

func (*JsonProcessor) MakeRawMsg

func (jsonProcessor *JsonProcessor) MakeRawMsg(msgType uint16, msg []byte) *JsonPackInfo

func (*JsonProcessor) Marshal

func (jsonProcessor *JsonProcessor) Marshal(clientId uint64, msg interface{}) ([]byte, error)

func (*JsonProcessor) MsgRoute

func (jsonProcessor *JsonProcessor) MsgRoute(clientId uint64, msg interface{}) error

must goroutine safe

func (*JsonProcessor) Register

func (jsonProcessor *JsonProcessor) Register(msgtype uint16, msg interface{}, handle MessageJsonHandler)

func (*JsonProcessor) RegisterConnected

func (jsonProcessor *JsonProcessor) RegisterConnected(connectHandler ConnectJsonHandler)

func (*JsonProcessor) RegisterDisConnected

func (jsonProcessor *JsonProcessor) RegisterDisConnected(disconnectHandler ConnectJsonHandler)

func (*JsonProcessor) RegisterUnknownMsg

func (jsonProcessor *JsonProcessor) RegisterUnknownMsg(unknownMessageHandler UnknownMessageJsonHandler)

func (*JsonProcessor) SetByteOrder

func (jsonProcessor *JsonProcessor) SetByteOrder(littleEndian bool)

func (*JsonProcessor) UnknownMsgRoute

func (jsonProcessor *JsonProcessor) UnknownMsgRoute(clientId uint64, msg interface{})

func (*JsonProcessor) Unmarshal

func (jsonProcessor *JsonProcessor) Unmarshal(clientId uint64, data []byte) (interface{}, error)

type MessageHandler

type MessageHandler func(clientId uint64, msg proto.Message)

type MessageInfo

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

type MessageJsonHandler

type MessageJsonHandler func(clientId uint64, msg interface{})

type MessageJsonInfo

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

type PBPackInfo

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

func (*PBPackInfo) GetMsg

func (slf *PBPackInfo) GetMsg() proto.Message

func (*PBPackInfo) GetPackType

func (slf *PBPackInfo) GetPackType() uint16

type PBProcessor

type PBProcessor struct {
	LittleEndian bool

	network.INetMempool
	// contains filtered or unexported fields
}

func NewPBProcessor

func NewPBProcessor() *PBProcessor

func (*PBProcessor) ConnectedRoute

func (pbProcessor *PBProcessor) ConnectedRoute(clientId uint64)

connect event

func (*PBProcessor) DisConnectedRoute

func (pbProcessor *PBProcessor) DisConnectedRoute(clientId uint64)

func (*PBProcessor) MakeMsg

func (pbProcessor *PBProcessor) MakeMsg(msgType uint16, protoMsg proto.Message) *PBPackInfo

func (*PBProcessor) MakeRawMsg

func (pbProcessor *PBProcessor) MakeRawMsg(msgType uint16, msg []byte) *PBPackInfo

func (*PBProcessor) Marshal

func (pbProcessor *PBProcessor) Marshal(clientId uint64, msg interface{}) ([]byte, error)

must goroutine safe

func (*PBProcessor) MsgRoute

func (pbProcessor *PBProcessor) MsgRoute(clientId uint64, msg interface{}) error

must goroutine safe

func (*PBProcessor) Register

func (pbProcessor *PBProcessor) Register(msgtype uint16, msg proto.Message, handle MessageHandler)

func (*PBProcessor) RegisterConnected

func (pbProcessor *PBProcessor) RegisterConnected(connectHandler ConnectHandler)

func (*PBProcessor) RegisterDisConnected

func (pbProcessor *PBProcessor) RegisterDisConnected(disconnectHandler ConnectHandler)

func (*PBProcessor) RegisterUnknownMsg

func (pbProcessor *PBProcessor) RegisterUnknownMsg(unknownMessageHandler UnknownMessageHandler)

func (*PBProcessor) SetByteOrder

func (pbProcessor *PBProcessor) SetByteOrder(littleEndian bool)

func (*PBProcessor) UnknownMsgRoute

func (pbProcessor *PBProcessor) UnknownMsgRoute(clientId uint64, msg interface{})

func (*PBProcessor) Unmarshal

func (pbProcessor *PBProcessor) Unmarshal(clientId uint64, data []byte) (interface{}, error)

must goroutine safe

type PBRawPackInfo

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

func (*PBRawPackInfo) GetMsg

func (slf *PBRawPackInfo) GetMsg() []byte

func (*PBRawPackInfo) GetPackType

func (slf *PBRawPackInfo) GetPackType() uint16

func (*PBRawPackInfo) SetPackInfo

func (slf *PBRawPackInfo) SetPackInfo(typ uint16, rawMsg []byte)

type PBRawProcessor

type PBRawProcessor struct {
	LittleEndian bool
	// contains filtered or unexported fields
}

func NewPBRawProcessor

func NewPBRawProcessor() *PBRawProcessor

func (*PBRawProcessor) ConnectedRoute

func (pbRawProcessor *PBRawProcessor) ConnectedRoute(clientId uint64)

connect event

func (*PBRawProcessor) DisConnectedRoute

func (pbRawProcessor *PBRawProcessor) DisConnectedRoute(clientId uint64)

func (*PBRawProcessor) MakeRawMsg

func (pbRawProcessor *PBRawProcessor) MakeRawMsg(msgType uint16, msg []byte, pbRawPackInfo *PBRawPackInfo)

func (*PBRawProcessor) Marshal

func (pbRawProcessor *PBRawProcessor) Marshal(clientId uint64, msg interface{}) ([]byte, error)

must goroutine safe

func (*PBRawProcessor) MsgRoute

func (pbRawProcessor *PBRawProcessor) MsgRoute(clientId uint64, msg interface{}) error

must goroutine safe

func (*PBRawProcessor) SetByteOrder

func (pbRawProcessor *PBRawProcessor) SetByteOrder(littleEndian bool)

func (*PBRawProcessor) SetConnectedHandler

func (pbRawProcessor *PBRawProcessor) SetConnectedHandler(connectHandler RawConnectHandler)

func (*PBRawProcessor) SetDisConnectedHandler

func (pbRawProcessor *PBRawProcessor) SetDisConnectedHandler(disconnectHandler RawConnectHandler)

func (*PBRawProcessor) SetRawMsgHandler

func (pbRawProcessor *PBRawProcessor) SetRawMsgHandler(handle RawMessageHandler)

func (*PBRawProcessor) SetUnknownMsgHandler

func (pbRawProcessor *PBRawProcessor) SetUnknownMsgHandler(unknownMessageHandler UnknownRawMessageHandler)

func (*PBRawProcessor) UnknownMsgRoute

func (pbRawProcessor *PBRawProcessor) UnknownMsgRoute(clientId uint64, msg interface{})

func (*PBRawProcessor) Unmarshal

func (pbRawProcessor *PBRawProcessor) Unmarshal(clientId uint64, data []byte) (interface{}, error)

must goroutine safe

type RawConnectHandler

type RawConnectHandler func(clientId uint64)

type RawMessageHandler

type RawMessageHandler func(clientId uint64, packType uint16, msg []byte)

type RawMessageInfo

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

type UnknownMessageHandler

type UnknownMessageHandler func(clientId uint64, msg []byte)

type UnknownMessageJsonHandler

type UnknownMessageJsonHandler func(clientId uint64, msg []byte)

type UnknownRawMessageHandler

type UnknownRawMessageHandler func(clientId uint64, msg []byte)

Jump to

Keyboard shortcuts

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