goev

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2023 License: MIT Imports: 4 Imported by: 3

Documentation

Index

Constants

View Source
const EV_MSG_TYPE_ATTACH = 1
View Source
const EV_MSG_TYPE_DETACH = 2
View Source
const EV_MSG_TYPE_MSG = 3

Variables

This section is empty.

Functions

This section is empty.

Types

type CallbackAddSession

type CallbackAddSession func(session Session)

type CallbackClose

type CallbackClose func(session Session, err error)

type CallbackMessage

type CallbackMessage func(session Session, hdr interface{}, payload []byte)

type CallbackTimer

type CallbackTimer func(sessions map[Session]time.Time)

type Codec

type Codec interface {
	// Encode function
	// :param msgId: message ID
	// :param payload: payload bytes
	// :return
	//   - []byte: encode result
	//   - error: error message
	Encode(msdId interface{}, payload []byte) ([]byte, error)

	// Decode function
	// :param reader: reader
	// :return
	//   - interface{}: message header
	//   - []byte: message payload
	//   - error: error message
	Decode(reader *bufio.Reader) (interface{}, []byte, error)
}

type Evloop

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

func NewEvloop

func NewEvloop() *Evloop

func (*Evloop) AddSession

func (this *Evloop) AddSession(session Session) error

func (*Evloop) Run

func (this *Evloop) Run()

func (*Evloop) SetCallbackOnAddConn

func (this *Evloop) SetCallbackOnAddConn(cb CallbackAddSession)

func (*Evloop) SetCallbackOnClose

func (this *Evloop) SetCallbackOnClose(cb CallbackClose)

func (*Evloop) SetCallbackOnMessage

func (this *Evloop) SetCallbackOnMessage(cb CallbackMessage)

func (*Evloop) SetCallbackOnTimer

func (this *Evloop) SetCallbackOnTimer(cb CallbackTimer)

func (*Evloop) SetTimerTick

func (this *Evloop) SetTimerTick(tick time.Duration)

type EvloopMsg

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

type Session

type Session interface {
	GetConn() net.Conn
	GetCodec() Codec
	GetUserData() interface{}
}

Directories

Path Synopsis
examples
client module
demo module
server module

Jump to

Keyboard shortcuts

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