ntk

package
v0.0.0-...-d73eb14 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2019 License: GPL-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const DEF_TIMER_KEEEP_CONNECT = 1 * time.Second // 保持连接状态

Variables

This section is empty.

Functions

This section is empty.

Types

type EMsgProMode

type EMsgProMode int //

处理消息的模式

const (
	EMPM_Single EMsgProMode = iota // 单线程[所有消息处理不并发]
	EMPM_Smart                     // 半智能[只有默认消息才并发]
	EMPM_Multi                     // 多线程[所有消息处理都并发]
)

func (EMsgProMode) String

func (e EMsgProMode) String() string

type ITConnMsgHandler

type ITConnMsgHandler interface {

	// 设置处理函数
	SetMsgHandler(msgType uint16, handle TConMsgHandleFunc)

	// 是否设置函数
	HasMsgHandler(msgType uint16) bool
}

TConnMsgHandle Interface

type ITcpConnectEer

type ITcpConnectEer interface {

	// 继承接口
	mss.IServicer

	// 异步发送消息
	SendMessage(msg ntc.IMsger, compres ...bool) error

	// 异步发送请求
	SentRequest(req ntc.IMsger, compres ...bool) error

	// 同步发送请求
	SendRequest(req ntc.IMsger, compres ...bool) (ntc.IMsger, error)

	// 异步发送请求[外部服务调用TcpConnect时使用]
	SencRequest(req ntc.IMsger, care mss.IServicer, ackFun TConMsgHandleFunc, compres ...bool) error

	// 异步转发请求[转发来自Client的请求时使用]
	TranRequest(req ntc.IMsger, handle TranAckHandleFunc, compres ...bool) error

	// 异步转发回应[服务于转发的请求,最终回应时调用]
	TranAcknowl(req, ack ntc.IMsger, compres ...bool) error
}

TcpConnect External Interface

type ITcpConnectVer

type ITcpConnectVer interface {
	mss.ISeriHandler

	// 处理连接成功
	HandleConnected(reconn bool)

	// 处理请求超时
	HandleReqTimeout(req ntc.IMsger)

	// 处理连接断开回调[只在被动关闭时触发]
	HandleDisConnect(reason error)
}

TcpConnect Virtual Interface

type ITcpServerEer

type ITcpServerEer interface {

	// 继承接口
	mss.IServicer

	// 发送消息
	SendMessage(msg ntc.IMsger, conId ntc.TConnId, compres ...bool) error

	// 转发请求
	TranRequest(req ntc.IMsger, conId ntc.TConnId, handle TranAckHandleFunc, compres ...bool) error
}

TcpServer External Interface

type ITcpServerVer

type ITcpServerVer interface {

	// 继承接口
	mss.ISeriHandler

	// 处理新进客户端
	HandleAccepted(cli ntc.IClienter)

	// 处理连接断开
	HandleDisClient(cli ntc.IClienter, remain []ntc.Packet, reason error)
}

TcpServer Virtual Interface

type TCliMsgHandleFunc

type TCliMsgHandleFunc func(ntc.IClienter, ntc.IMsger) error

type TCliMsgRouterFunc

type TCliMsgRouterFunc func(ntc.IClienter, ntc.IMsger) error

Server Client Msg Handler Fun

type TConMsgHandleFunc

type TConMsgHandleFunc func(mReq, mAck ntc.IMsger)

Connect tcp Handle fun

type TConnMsgHandle

type TConnMsgHandle struct {
	ILogMe
	// contains filtered or unexported fields
}

客户端消息处理封装

func (*TConnMsgHandle) AddReqHandle

func (this *TConnMsgHandle) AddReqHandle(req ntc.IMsger, care mss.IServicer, ackFun TConMsgHandleFunc)

func (*TConnMsgHandle) AddTranAckFun

func (this *TConnMsgHandle) AddTranAckFun(fun TranAckHandleFunc) uint32

func (*TConnMsgHandle) DelReqHandle

func (this *TConnMsgHandle) DelReqHandle(req ntc.IMsger)

func (*TConnMsgHandle) HandleMessage

func (this *TConnMsgHandle) HandleMessage(req, ack ntc.IMsger)

func (*TConnMsgHandle) HasMsgHandler

func (this *TConnMsgHandle) HasMsgHandler(msgType uint16) bool

func (*TConnMsgHandle) Init

func (this *TConnMsgHandle) Init(log ILogMe)

func (*TConnMsgHandle) SetMsgHandler

func (this *TConnMsgHandle) SetMsgHandler(msgType uint16, handle TConMsgHandleFunc)

func (*TConnMsgHandle) UpdReqHandle

func (this *TConnMsgHandle) UpdReqHandle(req, ack ntc.IMsger) bool

type TSerMsgRouter

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

服务端消息处理封装

func (*TSerMsgRouter) AddRouter

func (this *TSerMsgRouter) AddRouter(name string, handle TCliMsgRouterFunc) *TSerMsgRouter

func (*TSerMsgRouter) HasMsgHandler

func (this *TSerMsgRouter) HasMsgHandler(msgType uint16) bool

func (*TSerMsgRouter) SetMsgHandler

func (this *TSerMsgRouter) SetMsgHandler(msgType uint16, handle TCliMsgHandleFunc)

type TUdpMsgHandleFunc

type TUdpMsgHandleFunc func(msg ntc.IMsger)

Connect upd Handle fun

type TcpConnect

type TcpConnect struct {
	mss.ServiceHandle

	ntc.ITcpConner

	ITConnMsgHandler
	// contains filtered or unexported fields
}

func (*TcpConnect) GetReConnInterval

func (this *TcpConnect) GetReConnInterval() time.Duration

func (*TcpConnect) HandleConnected

func (this *TcpConnect) HandleConnected(reconn bool)

-------- Virtual

func (*TcpConnect) HandleDisConnect

func (this *TcpConnect) HandleDisConnect(reason error)

func (*TcpConnect) HandleInit

func (this *TcpConnect) HandleInit(own mss.ISeriOwner)

func (*TcpConnect) HandleReqTimeout

func (this *TcpConnect) HandleReqTimeout(req ntc.IMsger)

func (*TcpConnect) HandleStat

func (this *TcpConnect) HandleStat() string

func (*TcpConnect) HandleTerm

func (this *TcpConnect) HandleTerm(reason error)

func (*TcpConnect) OnTConnectErr

func (this *TcpConnect) OnTConnectErr(conndata interface{}, err error)

func (*TcpConnect) OnTConnectMsg

func (this *TcpConnect) OnTConnectMsg(conndata interface{}, req, ack ntc.IMsger)

func (*TcpConnect) OnTConnectOke

func (this *TcpConnect) OnTConnectOke(conndata interface{}, reconn bool)

------------------------------------------------------------------------------ ============================CallBack[TConnHandler]============================ ------------------------------------------------------------------------------

func (*TcpConnect) OnTConnectOut

func (this *TcpConnect) OnTConnectOut(conndata interface{}, req ntc.IMsger)

func (*TcpConnect) SencRequest

func (this *TcpConnect) SencRequest(req ntc.IMsger, care mss.IServicer, ackFun TConMsgHandleFunc, compres ...bool) error

------------------------------------------------------------------------------ ==================================Logical===================================== ------------------------------------------------------------------------------

func (*TcpConnect) SetReConnInterval

func (this *TcpConnect) SetReConnInterval(d time.Duration)

func (*TcpConnect) TranAcknowl

func (this *TcpConnect) TranAcknowl(req, ack ntc.IMsger, compres ...bool) error

func (*TcpConnect) TranRequest

func (this *TcpConnect) TranRequest(req ntc.IMsger, handle TranAckHandleFunc, compres ...bool) error

type TcpServer

type TcpServer struct {
	mss.ServiceHandle
	ntc.ITcpServer
	TSerMsgRouter
	// contains filtered or unexported fields
}

func (*TcpServer) AddPassedMsgs

func (this *TcpServer) AddPassedMsgs(msgTypes ...uint16)

func (*TcpServer) GetMsgProMode

func (this *TcpServer) GetMsgProMode() EMsgProMode

func (*TcpServer) HandleAccepted

func (this *TcpServer) HandleAccepted(cli ntc.IClienter)

-------- Virtual

func (*TcpServer) HandleDisClient

func (this *TcpServer) HandleDisClient(cli ntc.IClienter, remain []ntc.Packet, reason error)

func (*TcpServer) HandleInit

func (this *TcpServer) HandleInit(own mss.ISeriOwner)

func (*TcpServer) HandleLaun

func (this *TcpServer) HandleLaun()

func (*TcpServer) HandleStat

func (this *TcpServer) HandleStat() string

func (*TcpServer) HandleTerm

func (this *TcpServer) HandleTerm(reason error)

func (*TcpServer) OnTClientAccept

func (this *TcpServer) OnTClientAccept(cli ntc.IClienter)

func (*TcpServer) OnTClientErr

func (this *TcpServer) OnTClientErr(cli ntc.IClienter, remain []ntc.Packet, err error)

------------------------------------------------------------------------------ ===========================CallBack[TServerHandler]=========================== ------------------------------------------------------------------------------

func (*TcpServer) OnTClientMsg

func (this *TcpServer) OnTClientMsg(cli ntc.IClienter, msg ntc.IMsger)

func (*TcpServer) SetMsgProMode

func (this *TcpServer) SetMsgProMode(mode EMsgProMode)

------------------------------------------------------------------------------ ==================================Logical===================================== ------------------------------------------------------------------------------

func (*TcpServer) TranRequest

func (this *TcpServer) TranRequest(req ntc.IMsger, conId ntc.TConnId, fun TranAckHandleFunc, compres ...bool) error

-------- TransMessage

func (*TcpServer) UpdDefRouterf

func (this *TcpServer) UpdDefRouterf(name string, hfunc TCliMsgRouterFunc)

type TranAckHandleFunc

type TranAckHandleFunc func(ack ntc.IMsger) error

Trans req's ack Handle fun

type UdpConnect

type UdpConnect struct {
	mss.ServiceHandle
	ntc.IUdpConner
	// contains filtered or unexported fields
}

func (*UdpConnect) HandleInit

func (this *UdpConnect) HandleInit(own mss.ISeriOwner)

func (*UdpConnect) HandleStat

func (this *UdpConnect) HandleStat() string

func (*UdpConnect) HandleTerm

func (this *UdpConnect) HandleTerm(reason error)

func (*UdpConnect) HasMsgHandle

func (this *UdpConnect) HasMsgHandle(msgType uint16) bool

func (*UdpConnect) OnUConnectMsg

func (this *UdpConnect) OnUConnectMsg(msg ntc.IMsger)

----------------------------------------------------------------------------- ===============================UConnHandler================================== -----------------------------------------------------------------------------

func (*UdpConnect) SetMsgHandle

func (this *UdpConnect) SetMsgHandle(msgType uint16, handle TUdpMsgHandleFunc)

----------------------------------------------------------------------------- ================================PUBLIC接口==================================== -----------------------------------------------------------------------------

type UdpServer

type UdpServer struct {
	mss.ServiceHandle
	ntc.IUdpServer
	// contains filtered or unexported fields
}

func (*UdpServer) HandleInit

func (this *UdpServer) HandleInit(own mss.ISeriOwner)

func (*UdpServer) HandleStat

func (this *UdpServer) HandleStat() string

func (*UdpServer) HandleTerm

func (this *UdpServer) HandleTerm(reason error)

func (*UdpServer) HasMsgHandle

func (this *UdpServer) HasMsgHandle(msgType uint16) bool

func (*UdpServer) OnUClientMsg

func (this *UdpServer) OnUClientMsg(addr *net.UDPAddr, msg ntc.IMsger)

----------------------------------------------------------------------------- ==============================UServerHandler================================= -----------------------------------------------------------------------------

func (*UdpServer) SetMsgHandle

func (this *UdpServer) SetMsgHandle(msgType uint16, handle ntc.UMsgHandFunc)

----------------------------------------------------------------------------- ================================PUBLIC接口==================================== -----------------------------------------------------------------------------

Jump to

Keyboard shortcuts

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