Documentation
¶
Index ¶
- Constants
- func EnumCodeType(pertype func(code uint16, ty reflect.Type)) int
- func EnumNameType(pertype func(name string, ty reflect.Type)) int
- func Marshal(pb Message) ([]byte, error)
- func RegCliMsg(msgdir uint8, regpb Message, msg_func func(cli2sock *CLI2sock, inpb Message))
- func RegSvrMsg(msgdir uint8, regpb Message, ...)
- func RegSvrRPC(msgdir uint8, regpb Message, ...)
- func RegisterType(x Message)
- func SetMarshal(Marshal func(pb any) ([]byte, error))
- func SetUnmarshal(Unmarshal func(buf []byte, pb any) error)
- func Unmarshal(buf []byte, pb Message) error
- type CLI2base
- func (this *CLI2base) CLI2base(msgdir uint8, msgsvc CliMsgSvc, dbg, recv_concurr, cmdUseName bool, ...) *CLI2base
- func (this *CLI2base) GetMsgDir() uint8
- func (this *CLI2base) NotRegMessge(cli2sock *CLI2sock, msg string, rpk *RPacket, parse func() Message)
- func (this *CLI2base) OnConnect(datasock *Datasock) bool
- func (this *CLI2base) OnConnected(datasock *Datasock)
- func (this *CLI2base) OnDecode(datasock *Datasock, cipher []byte)
- func (this *CLI2base) OnDisconnected(datasock *Datasock, disc_reason int)
- func (this *CLI2base) OnEncode(datasock *Datasock, text []byte)
- func (this *CLI2base) OnProcPack(datasock *Datasock, rpk *RPacket)
- func (this *CLI2base) OnServeCall(datasock *Datasock, rpk *RPacket) (retcode int8, retwpk *WPacket)
- func (this *CLI2base) SwitchRoutine(cli2sock *CLI2sock, msg string, exefunc func())
- type CLI2sock
- func (this *CLI2sock) AiMain(fun_init, fun_idle func())
- func (this *CLI2sock) AiRunning() bool
- func (this *CLI2sock) AiStop()
- func (this *CLI2sock) CLI2sock(datasock *Datasock, cli2base *CLI2base, pktcmd_size uint32) *CLI2sock
- func (this *CLI2sock) Disconnect(discreason int, discfunc func()) int
- func (this *CLI2sock) GetMsgDir() uint8
- func (this *CLI2sock) GetUPlevel() any
- func (this *CLI2sock) IsConnected() bool
- func (this *CLI2sock) PostTask(cancel_all bool, task func() (cancel_all bool, new_tmout_ms int32))
- func (this *CLI2sock) Send2Cli(wpk *WPacket) error
- func (this *CLI2sock) SendProt(pb Message) error
- func (this *CLI2sock) SendProt4Ret(pb Message, tmout_ms int32, canbreak bool, retmsg []string, ...) (retpb Message, err int8)
- func (this *CLI2sock) SetUPlevel(uplevel any) (success bool)
- func (this *CLI2sock) Wait4Ret(tmout_ms int32, canbreak bool, retmsg []string, ...) (retpb Message, err int8)
- type CliMsgSvc
- type Datasock
- func (this *Datasock) AsynPack(tmot_ms uint32, in_para *WPacket, acb func(retcode int8, retval *RPacket)) error
- func (this *Datasock) Datasock(tcpconn *net.TCPConn, this_lsn *LsnSocket, ios *IOServer) *Datasock
- func (this *Datasock) Disconnect(discreason int, discfunc func()) int
- func (this *Datasock) GetCLI2sock() *CLI2sock
- func (this *Datasock) GetDiscError() error
- func (this *Datasock) GetEXSock() (curr_exsock any)
- func (this *Datasock) GetIOSvr() *IOServer
- func (this *Datasock) GetLocalAddr() string
- func (this *Datasock) GetLocalIP() string
- func (this *Datasock) GetLocalPort() uint16
- func (this *Datasock) GetPeerAddr() string
- func (this *Datasock) GetPeerIP() string
- func (this *Datasock) GetPeerPort() uint16
- func (this *Datasock) GetSVR2sock() *SVR2sock
- func (this *Datasock) IsServer() bool
- func (this *Datasock) SendPack(wpk *WPacket) error
- func (this *Datasock) SetEXSock(new_exsock any) (prev_exsock any)
- func (this *Datasock) SetReadBuffer(bins int) error
- func (this *Datasock) SetWriteBuffer(bins int) error
- func (this *Datasock) SyncPack(tmot_ms uint32, in_para *WPacket) (retcode int8, retval *RPacket)
- type GetMsgDir
- type IOSerivce
- type IOServer
- func (this *IOServer) CloseAllListen()
- func (this *IOServer) CloseListenByAddr(ip string, port uint16) error
- func (this *IOServer) CloseListenByPtr(lsn *LsnSocket) error
- func (this *IOServer) Connect(ip string, port uint16, concted func(*Datasock)) (*Datasock, error)
- func (this *IOServer) Connect2(target string, concted func(*Datasock)) (*Datasock, error)
- func (this *IOServer) GetExitFlag() *zbsync.Int32
- func (this *IOServer) GetRecvBytes() int64
- func (this *IOServer) GetRefCount() *zbsync.Int32
- func (this *IOServer) GetSendBytes() int64
- func (this *IOServer) GetSockNum() int
- func (this *IOServer) IOServer(iosvc IOSerivce, dbg, recv_concurr, sendblock_kick bool, ...) *IOServer
- func (this *IOServer) OpenListen(ip string, port uint16) error
- func (this *IOServer) SetPktParse(isenc bool, pktlen_size, pktses_size, pktcmd_size uint32)
- func (this *IOServer) SetReqChan(reqchan chan func())
- type LsnSocket
- type Message
- type PaktAsynRet
- type PeerLink
- func (this *PeerLink) GetBegTime() *time.Time
- func (this *PeerLink) GetConnected() bool
- func (this *PeerLink) GetPeerKind() uint8
- func (this *PeerLink) GetPeerLsnIP() []string
- func (this *PeerLink) GetPeerLsnPort() []uint32
- func (this *PeerLink) GetPeerName() string
- func (this *PeerLink) GetPeerVer() int32
- func (this *PeerLink) GetSVR2sock() *SVR2sock
- func (this *PeerLink) GetSvr2plyCount() int
- func (this *PeerLink) PeerLink(connected bool, svr2sock *SVR2sock, peerlsnip []string, peerlsnport []uint32, ...) *PeerLink
- type PeerMgr
- func (this *PeerMgr) DelPeerLink(peername string, svr2sock *SVR2sock) (sucs bool)
- func (this *PeerMgr) GetChanged() bool
- func (this *PeerMgr) GetCount() int
- func (this *PeerMgr) GetPeerLink(peername string) (link *PeerLink, found bool)
- func (this *PeerMgr) GetPeerLinks() map[string]*PeerLink
- func (this *PeerMgr) Iterate(iterfunc func(peername string, peerlink *PeerLink) (isbreak bool))
- func (this *PeerMgr) PeerMgr() *PeerMgr
- func (this *PeerMgr) SetChanged(changed bool)
- func (this *PeerMgr) SetPeerLink(peername string, link *PeerLink)
- type ProtAsynRet
- type RPacket
- func (this *RPacket) RPacket(iosvr *IOServer) *RPacket
- func (this *RPacket) ReadCmd() (cmd uint16)
- func (this *RPacket) ReadDouble() (dou float64)
- func (this *RPacket) ReadErrno() (errno uint16)
- func (this *RPacket) ReadFloat() (flo float32)
- func (this *RPacket) ReadInt1() (v int8)
- func (this *RPacket) ReadInt2() (v int16)
- func (this *RPacket) ReadInt4() (v int32)
- func (this *RPacket) ReadInt8() (v int64)
- func (this *RPacket) ReadSESS() uint32
- func (this *RPacket) ReadSequence() (seq []byte)
- func (this *RPacket) ReadString() (str string)
- func (this *RPacket) ReadUInt1() (v uint8)
- func (this *RPacket) ReadUInt2() (v uint16)
- func (this *RPacket) ReadUInt4() (v uint32)
- func (this *RPacket) ReadUInt8() (v uint64)
- func (this *RPacket) ReverseReadDouble() (dou float64)
- func (this *RPacket) ReverseReadFloat() (flo float32)
- func (this *RPacket) ReverseReadInt1() (v int8)
- func (this *RPacket) ReverseReadInt2() (v int16)
- func (this *RPacket) ReverseReadInt4() (v int32)
- func (this *RPacket) ReverseReadInt8() (v int64)
- func (this *RPacket) ReverseReadString() (str string)
- func (this *RPacket) ReverseReadUInt1() (v uint8)
- func (this *RPacket) ReverseReadUInt2() (v uint16)
- func (this *RPacket) ReverseReadUInt4() (v uint32)
- func (this *RPacket) ReverseReadUInt8() (v uint64)
- func (this *RPacket) WPacket(iosvr *IOServer) *WPacket
- func (this *RPacket) WriteCmd(cmd uint16) bool
- func (this *RPacket) WriteSESS(sessid uint32)
- type SVR2base
- func (this *SVR2base) BroadCastMsg(svr2sock *SVR2sock, svr2plys []*SVR2ply, msg string, rpk *RPacket)
- func (this *SVR2base) GetMsgDir() uint8
- func (this *SVR2base) NotRegMessge(svr2sock *SVR2sock, svr2ply *SVR2ply, msg string, rpk *RPacket, ...)
- func (this *SVR2base) OnConnect(datasock *Datasock) bool
- func (this *SVR2base) OnConnected(datasock *Datasock)
- func (this *SVR2base) OnDecode(datasock *Datasock, cipher []byte)
- func (this *SVR2base) OnDisconnected(datasock *Datasock, disc_reason int)
- func (this *SVR2base) OnEncode(datasock *Datasock, text []byte)
- func (this *SVR2base) OnProcPack(datasock *Datasock, rpk *RPacket)
- func (this *SVR2base) OnServeCall(datasock *Datasock, rpk *RPacket) (retcode int8, retwpk *WPacket)
- func (this *SVR2base) SVR2base(msgdir uint8, msgsvc SvrMsgSvc, dbg, recv_concurr, cmdUseName bool, ...) *SVR2base
- func (this *SVR2base) SwitchRoutine(svr2sock *SVR2sock, svr2ply *SVR2ply, msgname string, exefunc func())
- type SVR2ply
- func (this *SVR2ply) AiMain(fun_init, fun_idle func())
- func (this *SVR2ply) AiRunning() bool
- func (this *SVR2ply) AiStop()
- func (this *SVR2ply) AsynProt(tmot_ms uint32, msgdir GetMsgDir, in_para Message, ...) error
- func (this *SVR2ply) DelSockRelation(msgdir GetMsgDir) (myptr2peer uint32)
- func (this *SVR2ply) Get2PeerNum() int
- func (this *SVR2ply) GetMyPtr() uint32
- func (this *SVR2ply) GetOuter() any
- func (this *SVR2ply) GetPeerPtr(msgdir GetMsgDir) (peerptr2me uint32)
- func (this *SVR2ply) GetSVR2sock(msgdir GetMsgDir) *SVR2sock
- func (this *SVR2ply) Get_ISonline(msgdir GetMsgDir) bool
- func (this *SVR2ply) NewSockRelation(svr2sock *SVR2sock, peerptr2me uint32) (old_svr2sock *SVR2sock, old_peerptr2me uint32)
- func (this *SVR2ply) PostTask(cancel_all bool, task func() (cancel_all bool, new_tmout_ms int32))
- func (this *SVR2ply) SVR2ply(outer any) *SVR2ply
- func (this *SVR2ply) SendP2All(msgdir GetMsgDir, pb Message) error
- func (this *SVR2ply) SendPack(msgdir GetMsgDir, wpk *WPacket, memptr ...uint32) error
- func (this *SVR2ply) SendProt(msgdir GetMsgDir, pb Message, memptr ...uint32) error
- func (this *SVR2ply) SendProt4Ret(msgdir GetMsgDir, pb Message, tmout_ms int32, canbreak bool, retmsg []string, ...) (retpb Message, err int8)
- func (this *SVR2ply) SetPeerPtr(msgdir GetMsgDir, peerptr2me uint32)
- func (this *SVR2ply) SyncProt(tmot_ms uint32, msgdir GetMsgDir, in_para Message) (retcode int8, retpb Message)
- func (this *SVR2ply) Wait4Ret(tmout_ms int32, canbreak bool, retmsg []string, ...) (retpb Message, err int8)
- type SVR2sock
- func (this *SVR2sock) AddPlayer(svr2ply *SVR2ply)
- func (this *SVR2sock) AsynProt(tmot_ms uint32, svr2ply *SVR2ply, in_para Message, ...) error
- func (this *SVR2sock) ClearPlayer(PERplyOuter func(SVR2plyOuter any))
- func (this *SVR2sock) DelPlayer(svr2ply *SVR2ply)
- func (this *SVR2sock) Disconnect(discreason int, discfunc func()) int
- func (this *SVR2sock) FindSVR2ply(myptr2peer uint32) (svr2ply *SVR2ply, found bool)
- func (this *SVR2sock) Get2PeerNum() int
- func (this *SVR2sock) GetMsgDir() uint8
- func (this *SVR2sock) GetPeerKind() uint8
- func (this *SVR2sock) GetPeerName() string
- func (this *SVR2sock) GetSVR2PlyCount() int
- func (this *SVR2sock) IsConnected() bool
- func (this *SVR2sock) IteratePly(PERplyOuter func(SVR2plyOuter any) bool) any
- func (this *SVR2sock) SVR2sock(datasock *Datasock, svr2base *SVR2base, pktcmd_size uint32) *SVR2sock
- func (this *SVR2sock) SendP2All(pb Message) error
- func (this *SVR2sock) SendProt(svr2ply *SVR2ply, pb Message, memptr ...uint32) error
- func (this *SVR2sock) SetPeerKind(peerkind uint8)
- func (this *SVR2sock) SetPeerName(peername string)
- func (this *SVR2sock) SyncProt(tmot_ms uint32, svr2ply *SVR2ply, in_para Message, memptr ...uint32) (retcode int8, retpb Message)
- type SvrMsgSvc
- type WPacket
- func (this *WPacket) GetLen() int
- func (this *WPacket) RPacket(iosvr *IOServer) *RPacket
- func (this *WPacket) ReadCmd() (cmd uint16)
- func (this *WPacket) ReadSESS() uint32
- func (this *WPacket) WPacket(iosvr *IOServer) *WPacket
- func (this *WPacket) WriteCmd(cmd uint16) bool
- func (this *WPacket) WriteDouble(dou float64) bool
- func (this *WPacket) WriteErrno(errno uint16) bool
- func (this *WPacket) WriteFloat(flo float32) bool
- func (this *WPacket) WriteInt1(v int8) bool
- func (this *WPacket) WriteInt2(v int16) bool
- func (this *WPacket) WriteInt4(v int32) bool
- func (this *WPacket) WriteInt8(v int64) bool
- func (this *WPacket) WriteReverseString(str string) bool
- func (this *WPacket) WriteSESS(sessid uint32)
- func (this *WPacket) WriteSequence(seq []byte) bool
- func (this *WPacket) WriteString(str string) bool
- func (this *WPacket) WriteUInt1(v uint8) bool
- func (this *WPacket) WriteUInt2(v uint16) bool
- func (this *WPacket) WriteUInt4(v uint32) bool
- func (this *WPacket) WriteUInt8(v uint64) bool
Constants ¶
const INVALID_peer2iptr = 0
INVALID_peer2iptr peerptr2me=INVALID_peer2iptr表示无效值,会被忽略
Variables ¶
This section is empty.
Functions ¶
func RegSvrRPC ¶
func RegSvrRPC(msgdir uint8, regpb Message, rpc_func func(svr2sock *SVR2sock, svr2ply *SVR2ply, inpb Message, memptr ...uint32) (retcode int8, retpb Message))
RegSvrRPC 注册服务边Rpc相应函数
func RegisterType ¶
func RegisterType(x Message)
RegisterType is called from generated code and maps from the fully qualified proto name to the type (pointer to struct) of the protocol buffer.
func SetMarshal ¶
func SetUnmarshal ¶
Types ¶
type CLI2base ¶
type CLI2base struct { IOServer // contains filtered or unexported fields }
CLI2base 服务器面向客户端边的基础对象
func NewCLI2base ¶
func (*CLI2base) NotRegMessge ¶
func (*CLI2base) OnConnected ¶
func (*CLI2base) OnDisconnected ¶
func (*CLI2base) OnProcPack ¶
func (*CLI2base) OnServeCall ¶
func (*CLI2base) SwitchRoutine ¶
type CLI2sock ¶
CLI2sock 服务器面向客户端的socket
func (*CLI2sock) Disconnect ¶
func (*CLI2sock) GetUPlevel ¶
func (*CLI2sock) IsConnected ¶
func (*CLI2sock) SendProt4Ret ¶
func (*CLI2sock) SetUPlevel ¶
type CliMsgSvc ¶
type CliMsgSvc interface { IOSerivce SwitchRoutine(cli2sock *CLI2sock, msg string, exefunc func()) NotRegMessge(cli2sock *CLI2sock, msg string, rpk *RPacket, parse func() Message) }
CliMsgSvc 客户端消息服务接口
type Datasock ¶
type Datasock struct {
// contains filtered or unexported fields
}
Datasock 基础socket对象
func (*Datasock) Disconnect ¶
func (*Datasock) GetCLI2sock ¶
func (*Datasock) GetDiscError ¶
func (*Datasock) GetLocalAddr ¶
func (*Datasock) GetLocalIP ¶
func (*Datasock) GetLocalPort ¶
func (*Datasock) GetPeerAddr ¶
func (*Datasock) GetPeerPort ¶
func (*Datasock) GetSVR2sock ¶
func (*Datasock) SetReadBuffer ¶
func (*Datasock) SetWriteBuffer ¶
type IOSerivce ¶
type IOSerivce interface { OnConnect(datasock *Datasock) bool OnConnected(datasock *Datasock) OnDisconnected(datasock *Datasock, disc_reason int) OnEncode(datasock *Datasock, text []byte) OnDecode(datasock *Datasock, cipher []byte) OnProcPack(datasock *Datasock, rpk *RPacket) OnServeCall(datasock *Datasock, rpk *RPacket) (retcode int8, retwpk *WPacket) }
IOSerivce IO服务接口
type IOServer ¶
type IOServer struct {
// contains filtered or unexported fields
}
IOServer 服务的运行class
func (*IOServer) CloseListenByAddr ¶
CloseListenByAddr 关闭侦听端口ByAddr
func (*IOServer) CloseListenByPtr ¶
CloseListenByPtr 关闭侦听端口ByPtr
func (*IOServer) GetExitFlag ¶
func (*IOServer) GetRecvBytes ¶
func (*IOServer) GetRefCount ¶
func (*IOServer) GetSendBytes ¶
func (*IOServer) GetSockNum ¶
func (*IOServer) IOServer ¶
func (this *IOServer) IOServer(iosvc IOSerivce, dbg, recv_concurr, sendblock_kick bool, pktcombin zbrun.Runner, recvout_alive int16, sendout_alive int16, recv_delay_numMillis int) *IOServer
IOServer 构造函数
func (*IOServer) OpenListen ¶
OpenListen 打开侦听端口
func (*IOServer) SetPktParse ¶
func (*IOServer) SetReqChan ¶
func (this *IOServer) SetReqChan(reqchan chan func())
type LsnSocket ¶
type LsnSocket struct {
// contains filtered or unexported fields
}
LsnSocket 侦听端口表达
type Message ¶
type Message interface { proto.Message Reset() String() string ProtoMessage() GetMsgName() string GetMsgCode() uint16 GetThis() any }
Message is implemented by generated protocol buffer messages.
type PeerLink ¶
type PeerLink struct {
// contains filtered or unexported fields
}
PeerLink ----------------SVRreg-------------------------
func NewPeerLink ¶
func NewPeerLink0 ¶
func NewPeerLink0() *PeerLink
func (*PeerLink) GetBegTime ¶
func (*PeerLink) GetConnected ¶
func (*PeerLink) GetPeerKind ¶
func (*PeerLink) GetPeerLsnIP ¶
func (*PeerLink) GetPeerLsnPort ¶
func (*PeerLink) GetPeerName ¶
func (*PeerLink) GetPeerVer ¶
func (*PeerLink) GetSVR2sock ¶
func (*PeerLink) GetSvr2plyCount ¶
type PeerMgr ¶
PeerMgr 对端会话管理
func NewPeerMgr ¶
func NewPeerMgr() *PeerMgr
func (*PeerMgr) DelPeerLink ¶
func (*PeerMgr) GetChanged ¶
func (*PeerMgr) GetPeerLink ¶
func (*PeerMgr) GetPeerLinks ¶
func (*PeerMgr) SetChanged ¶
func (*PeerMgr) SetPeerLink ¶
type ProtAsynRet ¶
ProtAsynRet 异步返回message接口
func FetchProtAsynRet ¶
func FetchProtAsynRet() ProtAsynRet
type RPacket ¶
type RPacket struct {
// contains filtered or unexported fields
}
RPacket readable packet
func (*RPacket) ReadDouble ¶
func (*RPacket) ReadSequence ¶
func (*RPacket) ReadString ¶
func (*RPacket) ReverseReadDouble ¶
func (*RPacket) ReverseReadFloat ¶
func (*RPacket) ReverseReadInt1 ¶
func (*RPacket) ReverseReadInt2 ¶
func (*RPacket) ReverseReadInt4 ¶
func (*RPacket) ReverseReadInt8 ¶
func (*RPacket) ReverseReadString ¶
func (*RPacket) ReverseReadUInt1 ¶
func (*RPacket) ReverseReadUInt2 ¶
func (*RPacket) ReverseReadUInt4 ¶
func (*RPacket) ReverseReadUInt8 ¶
type SVR2base ¶
type SVR2base struct { IOServer // contains filtered or unexported fields }
SVR2base Server边基础对象
func (*SVR2base) BroadCastMsg ¶
func (*SVR2base) NotRegMessge ¶
func (*SVR2base) OnConnected ¶
func (*SVR2base) OnDisconnected ¶
func (*SVR2base) OnProcPack ¶
func (*SVR2base) OnServeCall ¶
type SVR2ply ¶
type SVR2ply struct {
// contains filtered or unexported fields
}
SVR2ply Server上的player对象表示
func NewSVR2ply ¶
func (*SVR2ply) DelSockRelation ¶
func (*SVR2ply) Get2PeerNum ¶
func (*SVR2ply) GetPeerPtr ¶
func (*SVR2ply) GetSVR2sock ¶
func (*SVR2ply) Get_ISonline ¶
func (*SVR2ply) NewSockRelation ¶
func (this *SVR2ply) NewSockRelation(svr2sock *SVR2sock, peerptr2me uint32) (old_svr2sock *SVR2sock, old_peerptr2me uint32)
NewSockRelation peerptr2me=INVALID_PEER2IPTR表示无效值,会被忽略
func (*SVR2ply) SendProt4Ret ¶
func (*SVR2ply) SetPeerPtr ¶
SetPeerPtr 设置本地标记对端的数字指针
type SVR2sock ¶
SVR2sock 面向server边的socket
func (*SVR2sock) ClearPlayer ¶
func (*SVR2sock) Disconnect ¶
func (*SVR2sock) FindSVR2ply ¶
func (*SVR2sock) Get2PeerNum ¶
func (*SVR2sock) GetPeerKind ¶
func (*SVR2sock) GetPeerName ¶
func (*SVR2sock) GetSVR2PlyCount ¶
func (*SVR2sock) IsConnected ¶
func (*SVR2sock) IteratePly ¶
func (*SVR2sock) SetPeerKind ¶
func (*SVR2sock) SetPeerName ¶
type SvrMsgSvc ¶
type SvrMsgSvc interface { IOSerivce SwitchRoutine(svr2sock *SVR2sock, svr2ply *SVR2ply, msg string, exefunc func()) NotRegMessge(svr2sock *SVR2sock, svr2ply *SVR2ply, msg string, rpk *RPacket, parse func() Message, memptr ...uint32) BroadCastMsg(svr2sock *SVR2sock, svr2plys []*SVR2ply, msg string, rpk *RPacket) }
SvrMsgSvc 服务器消息服务接口
type WPacket ¶
type WPacket struct {
// contains filtered or unexported fields
}
WPacket writable packet