handler

package
v0.0.0-...-6384d94 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Base

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

Base handler base

func (*Base) Conn

func (h *Base) Conn() net.Conn

Conn get conn

func (*Base) Dispose

func (h *Base) Dispose()

Dispose clean your resource if need

func (*Base) Execute

func (h *Base) Execute(buff []byte)

Execute handler base virtual function of Execute

func (*Base) GetBase

func (h *Base) GetBase() *Base

GetBase handler base virtual function of GetBase

func (*Base) Receive

func (h *Base) Receive(para *CommObj)

Receive handler base virtual function of Receive

func (*Base) SetConn

func (h *Base) SetConn(c net.Conn)

SetConn set conn

type CommObj

type CommObj struct {
	Src message.CmdType
	Dst message.CmdType
	Obj []interface{}
}

CommObj use for communication of handlers

func NewCommObj

func NewCommObj(s message.CmdType, d message.CmdType, o ...interface{}) *CommObj

NewCommObj ...

type Handler

type Handler interface {
	//GetBase get base type
	GetBase() *Base
	//Execute process package
	Execute(buff []byte)
	//Receive receive message from other handler
	Receive(para *CommObj)
}

Handler process package

type Manager

type Manager struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Manager ...

func (*Manager) Add

func (manager *Manager) Add(msgType message.CmdType, handler Handler)

Add add handlers, when msgType is 0, it means this is a data packet

func (*Manager) Foreach

func (manager *Manager) Foreach(f func(message.CmdType, Handler))

Foreach traversal handlers

func (*Manager) Get

func (manager *Manager) Get(msgType message.CmdType) Handler

Get get the handler

Jump to

Keyboard shortcuts

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