Documentation ¶
Index ¶
- Constants
- type EMsgProMode
- type ITConnMsgHandler
- type ITcpConnectEer
- type ITcpConnectVer
- type ITcpServerEer
- type ITcpServerVer
- type TCliMsgHandleFunc
- type TCliMsgRouterFunc
- type TConMsgHandleFunc
- type TConnMsgHandle
- func (this *TConnMsgHandle) AddReqHandle(req ntc.IMsger, care mss.IServicer, ackFun TConMsgHandleFunc)
- func (this *TConnMsgHandle) AddTranAckFun(fun TranAckHandleFunc) uint32
- func (this *TConnMsgHandle) DelReqHandle(req ntc.IMsger)
- func (this *TConnMsgHandle) HandleMessage(req, ack ntc.IMsger)
- func (this *TConnMsgHandle) HasMsgHandler(msgType uint16) bool
- func (this *TConnMsgHandle) Init(log ILogMe)
- func (this *TConnMsgHandle) SetMsgHandler(msgType uint16, handle TConMsgHandleFunc)
- func (this *TConnMsgHandle) UpdReqHandle(req, ack ntc.IMsger) bool
- type TSerMsgRouter
- type TUdpMsgHandleFunc
- type TcpConnect
- func (this *TcpConnect) GetReConnInterval() time.Duration
- func (this *TcpConnect) HandleConnected(reconn bool)
- func (this *TcpConnect) HandleDisConnect(reason error)
- func (this *TcpConnect) HandleInit(own mss.ISeriOwner)
- func (this *TcpConnect) HandleReqTimeout(req ntc.IMsger)
- func (this *TcpConnect) HandleStat() string
- func (this *TcpConnect) HandleTerm(reason error)
- func (this *TcpConnect) OnTConnectErr(conndata interface{}, err error)
- func (this *TcpConnect) OnTConnectMsg(conndata interface{}, req, ack ntc.IMsger)
- func (this *TcpConnect) OnTConnectOke(conndata interface{}, reconn bool)
- func (this *TcpConnect) OnTConnectOut(conndata interface{}, req ntc.IMsger)
- func (this *TcpConnect) SencRequest(req ntc.IMsger, care mss.IServicer, ackFun TConMsgHandleFunc, compres ...bool) error
- func (this *TcpConnect) SetReConnInterval(d time.Duration)
- func (this *TcpConnect) TranAcknowl(req, ack ntc.IMsger, compres ...bool) error
- func (this *TcpConnect) TranRequest(req ntc.IMsger, handle TranAckHandleFunc, compres ...bool) error
- type TcpServer
- func (this *TcpServer) AddPassedMsgs(msgTypes ...uint16)
- func (this *TcpServer) GetMsgProMode() EMsgProMode
- func (this *TcpServer) HandleAccepted(cli ntc.IClienter)
- func (this *TcpServer) HandleDisClient(cli ntc.IClienter, remain []ntc.Packet, reason error)
- func (this *TcpServer) HandleInit(own mss.ISeriOwner)
- func (this *TcpServer) HandleLaun()
- func (this *TcpServer) HandleStat() string
- func (this *TcpServer) HandleTerm(reason error)
- func (this *TcpServer) OnTClientAccept(cli ntc.IClienter)
- func (this *TcpServer) OnTClientErr(cli ntc.IClienter, remain []ntc.Packet, err error)
- func (this *TcpServer) OnTClientMsg(cli ntc.IClienter, msg ntc.IMsger)
- func (this *TcpServer) SetMsgProMode(mode EMsgProMode)
- func (this *TcpServer) TranRequest(req ntc.IMsger, conId ntc.TConnId, fun TranAckHandleFunc, compres ...bool) error
- func (this *TcpServer) UpdDefRouterf(name string, hfunc TCliMsgRouterFunc)
- type TranAckHandleFunc
- type UdpConnect
- func (this *UdpConnect) HandleInit(own mss.ISeriOwner)
- func (this *UdpConnect) HandleStat() string
- func (this *UdpConnect) HandleTerm(reason error)
- func (this *UdpConnect) HasMsgHandle(msgType uint16) bool
- func (this *UdpConnect) OnUConnectMsg(msg ntc.IMsger)
- func (this *UdpConnect) SetMsgHandle(msgType uint16, handle TUdpMsgHandleFunc)
- type UdpServer
- func (this *UdpServer) HandleInit(own mss.ISeriOwner)
- func (this *UdpServer) HandleStat() string
- func (this *UdpServer) HandleTerm(reason error)
- func (this *UdpServer) HasMsgHandle(msgType uint16) bool
- func (this *UdpServer) OnUClientMsg(addr *net.UDPAddr, msg ntc.IMsger)
- func (this *UdpServer) SetMsgHandle(msgType uint16, handle ntc.UMsgHandFunc)
Constants ¶
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 TCliMsgRouterFunc ¶
Server Client Msg Handler 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 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 (*TcpServer) GetMsgProMode ¶
func (this *TcpServer) GetMsgProMode() EMsgProMode
func (*TcpServer) HandleAccepted ¶
-------- Virtual
func (*TcpServer) HandleDisClient ¶
func (*TcpServer) HandleInit ¶
func (this *TcpServer) HandleInit(own mss.ISeriOwner)
func (*TcpServer) HandleLaun ¶
func (this *TcpServer) HandleLaun()
func (*TcpServer) HandleStat ¶
func (*TcpServer) HandleTerm ¶
func (*TcpServer) OnTClientAccept ¶
func (*TcpServer) OnTClientErr ¶
------------------------------------------------------------------------------ ===========================CallBack[TServerHandler]=========================== ------------------------------------------------------------------------------
func (*TcpServer) OnTClientMsg ¶
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 ¶
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 (*UdpServer) HandleTerm ¶
func (*UdpServer) HasMsgHandle ¶
func (*UdpServer) OnUClientMsg ¶
----------------------------------------------------------------------------- ==============================UServerHandler================================= -----------------------------------------------------------------------------
func (*UdpServer) SetMsgHandle ¶
func (this *UdpServer) SetMsgHandle(msgType uint16, handle ntc.UMsgHandFunc)
----------------------------------------------------------------------------- ================================PUBLIC接口==================================== -----------------------------------------------------------------------------