gnetwork

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2020 License: LGPL-3.0 Imports: 8 Imported by: 0

README

gnetwork

介绍

一个简单的Reactor网络封装.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultPackHeaderFlags = 0x169
View Source
var DefaultPackSizeMax = 0x7FF
View Source
var ErrorNonstandard = errors.New("数据包异常.")
View Source
var PackHeaderSize int

Functions

func BuildPackData

func BuildPackData(data []byte) []byte

func ParserPackHeader

func ParserPackHeader(content []byte) (l int, err error)

ParserPackHeader 解析包头

Types

type Control

type Control interface {
	Launch() int32
	Run()
	StopAndWait()
}

type DefaultEvHandle

type DefaultEvHandle struct {
}

func (*DefaultEvHandle) OnAccept

func (self *DefaultEvHandle) OnAccept(connId int32, conn net.Conn)

func (*DefaultEvHandle) OnClosed

func (self *DefaultEvHandle) OnClosed(connId int32)

func (*DefaultEvHandle) OnError

func (self *DefaultEvHandle) OnError(err error)

func (*DefaultEvHandle) OnFinish

func (self *DefaultEvHandle) OnFinish(id int32)

func (*DefaultEvHandle) OnReceived

func (self *DefaultEvHandle) OnReceived(connId int32, content []byte) error

type ErrorHandle

type ErrorHandle interface {
	OnError(err error)
}

type EvLoopQueOp

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

func NewEvLoopQueOp

func NewEvLoopQueOp(queSize uint32) *EvLoopQueOp

func (EvLoopQueOp) GetValue

func (self EvLoopQueOp) GetValue() interface{}

type IOHandle

type IOHandle interface {
	// contains filtered or unexported methods
}

type ITcpHandle

type ITcpHandle interface {
	ErrorHandle
	OnAccept(connId int32, conn net.Conn)
	//OnReceived 对于一个connect来说是同步的
	OnReceived(connId int32, content []byte) error
	OnClosed(connId int32)
	OnFinish(id int32)
}

type ITcpPackRegulator

type ITcpPackRegulator interface {
	ParserPackHeader(content []byte) (l int, err error)
	BuildPackData(data []byte) []byte
}

type Option

type Option interface {
	GetValue() interface{}
}

type PackHeader

type PackHeader struct {
	Flag int32
}

type TcpPackServe

type TcpPackServe struct {
	*TcpServe
	// contains filtered or unexported fields
}

func NewTcpPackServe

func NewTcpPackServe(tcp *TcpServe, hSize int, regulator ITcpPackRegulator) *TcpPackServe

func (*TcpPackServe) SendData

func (self *TcpPackServe) SendData(connId int32, data []byte)

func (*TcpPackServe) SyncSendData

func (self *TcpPackServe) SyncSendData(connId int32, data []byte) bool

type TcpServe

type TcpServe struct {
	gevent.DefaultEventReactor
	IOHandle
	// contains filtered or unexported fields
}

func NewTcpServe

func NewTcpServe(cxt context.Context, listener net.Listener, cb ITcpHandle, options ...Option) *TcpServe

func (*TcpServe) CloseConn

func (self *TcpServe) CloseConn(connId int32)

func (*TcpServe) IsExistConnId

func (self *TcpServe) IsExistConnId(connId int32) bool

func (*TcpServe) Launch

func (self *TcpServe) Launch() int32

func (*TcpServe) OnCmdHandle

func (self *TcpServe) OnCmdHandle(id int32, evCmd int64, extras []interface{})

func (*TcpServe) OnFinishEventLoop

func (self *TcpServe) OnFinishEventLoop(id int32)

func (*TcpServe) Run

func (self *TcpServe) Run()

func (*TcpServe) SendData

func (self *TcpServe) SendData(connId int32, data []byte)

func (*TcpServe) StopAndWait

func (self *TcpServe) StopAndWait()

func (*TcpServe) SyncSendData

func (self *TcpServe) SyncSendData(connId int32, data []byte) bool

Jump to

Keyboard shortcuts

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