Documentation ¶
Index ¶
- Constants
- type BSocketConnInfo
- type BTcpClient
- func (t *BTcpClient) FreeBs(bs []byte) error
- func (t *BTcpClient) GetId() uint32
- func (t *BTcpClient) GetLocalAddr() (string, int)
- func (t *BTcpClient) GetPacketSize() int
- func (t *BTcpClient) GetRemoteAddr() (string, int)
- func (t *BTcpClient) GetStatus() (bool, time.Time)
- func (t *BTcpClient) SendData(bs []byte) (int, error)
- func (t *BTcpClient) SetFnTcpClientConn(fnconn FnTcpClientConn) error
- func (t *BTcpClient) SetFnTcpClientDisConn(fndisconn FnTcpClientDisConn) error
- func (t *BTcpClient) SetFnTcpClientRcvData(fnrecv FnTcpClientRcvData) error
- func (t *BTcpClient) SetId(classid uint32) error
- func (t *BTcpClient) SetLocalAddr(localip string, localport int) error
- func (t *BTcpClient) SetNotifyThread(notifythread IBaseThread) error
- func (t *BTcpClient) SetPacketSize(packetsize int) error
- func (t *BTcpClient) SetRemoteAddr(remoteip string, remoteport int) error
- func (t *BTcpClient) Start() error
- func (t *BTcpClient) Stop() error
- type BTcpServer
- func (t *BTcpServer) CloseAllClient() error
- func (t *BTcpServer) CloseClient(clientid uint32) error
- func (t *BTcpServer) FreeBs(bs []byte) error
- func (t *BTcpServer) GetAllClient() *list.TList
- func (t *BTcpServer) GetId() uint32
- func (t *BTcpServer) GetLocalAddr() (string, int)
- func (t *BTcpServer) GetPacketSize() int
- func (t *BTcpServer) GetStatus() (bool, time.Time)
- func (t *BTcpServer) SendData(clientid uint32, bs []byte) (int, error)
- func (t *BTcpServer) SetFnTcpServerConn(fnconn FnTcpServerConn) error
- func (t *BTcpServer) SetFnTcpServerDisConn(fndisconn FnTcpServerDisConn) error
- func (t *BTcpServer) SetFnTcpServerRcvData(fnrecv FnTcpServerRcvData) error
- func (t *BTcpServer) SetFnTcpServerStart(fnstart FnTcpServerStart) error
- func (t *BTcpServer) SetFnUdpStop(fnstop FnTcpServerStop) error
- func (t *BTcpServer) SetId(classid uint32) error
- func (t *BTcpServer) SetLocalAddr(localip string, localport int) error
- func (t *BTcpServer) SetNotifyThread(notifythread IBaseThread) error
- func (t *BTcpServer) SetPacketSize(packetsize int) error
- func (t *BTcpServer) Start() error
- func (t *BTcpServer) Stop() error
- type BUdp
- func (t *BUdp) FreeBs(bs []byte) error
- func (t *BUdp) GetId() uint32
- func (t *BUdp) GetLocalAddr() (string, int)
- func (t *BUdp) GetPacketSize() int
- func (t *BUdp) GetRemoteAddr() (string, int)
- func (t *BUdp) GetStatus() (bool, time.Time)
- func (t *BUdp) SendData(bs []byte) (int, error)
- func (t *BUdp) SendDataTo(remoteip string, remoteport int, bs []byte) (int, error)
- func (t *BUdp) SetFnUdpRcvData(fnrecv FnUdpRcvData) error
- func (t *BUdp) SetFnUdpStart(fnstart FnUdpStart) error
- func (t *BUdp) SetFnUdpStop(fnstop FnUdpStop) error
- func (t *BUdp) SetId(classid uint32) error
- func (t *BUdp) SetLocalAddr(localip string, localport int) error
- func (t *BUdp) SetNotifyThread(notifythread IBaseThread) error
- func (t *BUdp) SetPacketSize(packetsize int) error
- func (t *BUdp) SetRemoteAddr(remoteip string, remoteport int) error
- func (t *BUdp) Start() error
- func (t *BUdp) Stop() error
- type BaseTcpClient
- func (t *BaseTcpClient) AddTcpClient(clientid uint32, localip string, localport int, remoteip string, ...) error
- func (t *BaseTcpClient) AddTcpClientWithCallback(clientid uint32, localip string, localport int, remoteip string, ...) error
- func (t *BaseTcpClient) ClearTcpClient() error
- func (t *BaseTcpClient) DelTcpClient(clientid uint32) error
- func (t *BaseTcpClient) FreeBs(bs []byte) error
- func (t *BaseTcpClient) GetTcpClientInfo(clientid uint32) (bool, *time.Time, string, int, string, int, error)
- func (t *BaseTcpClient) SendData(clientid uint32, bs []byte) (int, error)
- func (t *BaseTcpClient) SetFnTcpClientConn(fntcpclientconn FnTcpClientConn) error
- func (t *BaseTcpClient) SetFnTcpClientDisConn(fntcpclientdisconn FnTcpClientDisConn) error
- func (t *BaseTcpClient) SetFnTcpClientRcvData(fntcpclientrcvdata FnTcpClientRcvData) error
- func (t *BaseTcpClient) SetNotifyThread(notifythread IBaseThread) error
- func (t *BaseTcpClient) StartTcpClient(clientid uint32) error
- func (t *BaseTcpClient) StopTcpClient(clientid uint32) error
- type BaseThread
- func (t *BaseThread) DoWithMsg(classId uint32, msgId uint32, wParam uint64, lParam uint64, wInfo string, ...) int
- func (t *BaseThread) Init() int
- func (t *BaseThread) InitilizeThread(classId uint32, name string, fnInit FnInit, fnUnInit FnUnInit, ...) error
- func (t *BaseThread) IsStart() bool
- func (t *BaseThread) PostComplexMsg(classId uint32, msgId uint32, wParam uint64, lParam uint64, wInfo string, ...) error
- func (t *BaseThread) PostMsg(msgId uint32, wParam uint64, lParam uint64) error
- func (t *BaseThread) Start() error
- func (t *BaseThread) Stop() error
- func (t *BaseThread) UnInit() int
- func (t *BaseThread) WaitExit() error
- type BaseTimer
- func (t *BaseTimer) AddCronTimer(timerid uint32, cron string, param uint64, info string, ...) error
- func (t *BaseTimer) AddCycleTimer(timerid uint32, timerlen int, param uint64, info string, ...) error
- func (t *BaseTimer) AddOnceTimer(timerid uint32, timerlen int, param uint64, info string, ...) error
- func (t *BaseTimer) ClearTimer() error
- func (t *BaseTimer) DelTimer(timerid uint32) error
- func (t *BaseTimer) StartTimer() error
- func (t *BaseTimer) StopTimer() error
- type BaseUdp
- func (t *BaseUdp) AddUdp(udpid uint32, localip string, localport int) error
- func (t *BaseUdp) AddUdpWithCallback(udpid uint32, localip string, localport int, notifythread IBaseThread, ...) error
- func (t *BaseUdp) ClearUdp() error
- func (t *BaseUdp) DelUdp(udpid uint32) error
- func (t *BaseUdp) FreeBs(bs []byte) error
- func (t *BaseUdp) GetUdpInfo(udpid uint32) (bool, *time.Time, string, int, error)
- func (t *BaseUdp) SendData(udpid uint32, remoteip string, remoteport int, bs []byte) (int, error)
- func (t *BaseUdp) SetFnUdpRcvData(fnduprcvdata FnUdpRcvData) error
- func (t *BaseUdp) SetFnUdpStart(fnudpstart FnUdpStart) error
- func (t *BaseUdp) SetFnUdpStop(fnudpstop FnUdpStop) error
- func (t *BaseUdp) SetNotifyThread(notifythread IBaseThread) error
- func (t *BaseUdp) StartUdp(udpid uint32) error
- func (t *BaseUdp) StopUdp(udpid uint32) error
- type BytebufferPool
- type FnDoWithMsg
- type FnInit
- type FnOnTimer
- type FnTcpClientConn
- type FnTcpClientDisConn
- type FnTcpClientRcvData
- type FnTcpServerConn
- type FnTcpServerDisConn
- type FnTcpServerRcvData
- type FnTcpServerStart
- type FnTcpServerStop
- type FnUdpRcvData
- type FnUdpStart
- type FnUdpStop
- type FnUnInit
- type IBaseThread
- type TMemStream
Constants ¶
const ( WM_THREAD_START uint32 = 1 << 28 //线程退出消息 WM_THREAD_EXIT = WM_THREAD_START + 99 //========================================================================= WM_TCPSERVER_STARTED = WM_THREAD_START + 100 /* ClassId uint32 发送消息的对象id MsgId uint32 WM_TCPSERVER_STARTED WParam uint64 server_id LParam uint64 local_port WInfo string LInfo string local_ip OtherInfo interface{} * */ WM_TCPSERVER_STOPPED = WM_THREAD_START + 110 /* ClassId uint32 发送消息的对象id MsgId uint32 WM_TCPSERVER_STOPPED WParam uint64 server_id LParam uint64 local_port WInfo string LInfo string local_ip OtherInfo interface{} * */ WM_TCPSERVER_CLIENT_CONNECTED = WM_THREAD_START + 120 /* ClassId uint32 发送消息的对象id MsgId uint32 WM_TCPSERVER_CLIENT_CONNECTED WParam uint64 server_id | client_id LParam uint64 local_port | remote_port WInfo string remote_ip LInfo string local_ip OtherInfo interface{} * */ WM_TCPSERVER_CLIENT_DISCONNECTED = WM_THREAD_START + 130 /* ClassId uint32 发送消息的对象id MsgId uint32 WM_TCPSERVER_CLIENT_DISCONNECTED WParam uint64 server_id | client_id LParam uint64 local_port | remote_port WInfo string remote_ip LInfo string local_ip OtherInfo interface{} * */ WM_TCPSERVER_CLIENT_RCV_DATA = WM_THREAD_START + 140 WM_TCPCLIENT_CONNECTED = WM_THREAD_START + 220 WM_TCPCLIENT_DISCONNECTED = WM_THREAD_START + 230 /* ClassId uint32 发送消息的对象id MsgId uint32 WM_TCPCLIENT_CLIENT_DISCONNECTED WParam uint64 client_id LParam uint64 local_port | remote_port WInfo string remote_ip LInfo string local_ip OtherInfo interface{} * */ WM_TCPCLIENT_RCV_DATA = WM_THREAD_START + 240 //========================================================================= WM_UDP_STARTED = WM_THREAD_START + 300 /* ClassId uint32 发送消息的对象id MsgId uint32 WM_UDP_STARTED WParam uint64 udp_id LParam uint64 local_port WInfo string LInfo string local_ip OtherInfo interface{} * */ WM_UDP_STOPPED = WM_THREAD_START + 310 /* ClassId uint32 发送消息的对象id MsgId uint32 WM_UDP_STOPPED WParam uint64 udp_id LParam uint64 local_port WInfo string LInfo string local_ip OtherInfo interface{} * */ WM_UDP_RCV_DATA = WM_THREAD_START + 340 //============================================================ WM_TIMER = WM_THREAD_START + 400 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BSocketConnInfo ¶
type BSocketConnInfo struct { ConnType string //连接类型 upd tcp ConnClassId uint32 //归属kapp对象编号 ConnServerId uint32 //归属服务器编号 ConnId uint32 //连接编号 LocalIp string //本地地址 LocalPort int //本地端口 RemoteIp string //远端地址 RemotePort int //远端端口 IsStart bool //是否处于启动状态 EventTime time.Time //停止或者启动时间 }
func (*BSocketConnInfo) String ¶
func (t *BSocketConnInfo) String() string
type BTcpClient ¶
type BTcpClient struct {
// contains filtered or unexported fields
}
=================tcpclient节点
func (*BTcpClient) GetId ¶
func (t *BTcpClient) GetId() uint32
func (*BTcpClient) GetLocalAddr ¶
func (t *BTcpClient) GetLocalAddr() (string, int)
func (*BTcpClient) GetPacketSize ¶
func (t *BTcpClient) GetPacketSize() int
func (*BTcpClient) GetRemoteAddr ¶
func (t *BTcpClient) GetRemoteAddr() (string, int)
func (*BTcpClient) SetFnTcpClientConn ¶
func (t *BTcpClient) SetFnTcpClientConn(fnconn FnTcpClientConn) error
设置回调函数 - 启动通知
func (*BTcpClient) SetFnTcpClientDisConn ¶
func (t *BTcpClient) SetFnTcpClientDisConn(fndisconn FnTcpClientDisConn) error
设置回调函数 - 停止通知
func (*BTcpClient) SetFnTcpClientRcvData ¶
func (t *BTcpClient) SetFnTcpClientRcvData(fnrecv FnTcpClientRcvData) error
设置回调函数 - 收到数据通知
func (*BTcpClient) SetLocalAddr ¶
func (t *BTcpClient) SetLocalAddr(localip string, localport int) error
设置本地地址信息
func (*BTcpClient) SetNotifyThread ¶
func (t *BTcpClient) SetNotifyThread(notifythread IBaseThread) error
设置通知协程
func (*BTcpClient) SetRemoteAddr ¶
func (t *BTcpClient) SetRemoteAddr(remoteip string, remoteport int) error
设置远端地址信息
type BTcpServer ¶
type BTcpServer struct {
// contains filtered or unexported fields
}
==============================================================================
func (*BTcpServer) CloseClient ¶
func (t *BTcpServer) CloseClient(clientid uint32) error
关闭TcpClient
func (*BTcpServer) GetAllClient ¶
func (t *BTcpServer) GetAllClient() *list.TList
获取所有客户端列表TcpClient
func (*BTcpServer) GetId ¶
func (t *BTcpServer) GetId() uint32
func (*BTcpServer) GetLocalAddr ¶
func (t *BTcpServer) GetLocalAddr() (string, int)
func (*BTcpServer) GetPacketSize ¶
func (t *BTcpServer) GetPacketSize() int
func (*BTcpServer) SendData ¶
func (t *BTcpServer) SendData(clientid uint32, bs []byte) (int, error)
发送数据
func (*BTcpServer) SetFnTcpServerConn ¶
func (t *BTcpServer) SetFnTcpServerConn(fnconn FnTcpServerConn) error
设置回调函数 - 客户端连接通知
func (*BTcpServer) SetFnTcpServerDisConn ¶
func (t *BTcpServer) SetFnTcpServerDisConn(fndisconn FnTcpServerDisConn) error
设置回调函数 - 客户端断开连接通知
func (*BTcpServer) SetFnTcpServerRcvData ¶
func (t *BTcpServer) SetFnTcpServerRcvData(fnrecv FnTcpServerRcvData) error
设置回调函数 - 收到数据通知
func (*BTcpServer) SetFnTcpServerStart ¶
func (t *BTcpServer) SetFnTcpServerStart(fnstart FnTcpServerStart) error
设置回调函数 - 启动通知
func (*BTcpServer) SetFnUdpStop ¶
func (t *BTcpServer) SetFnUdpStop(fnstop FnTcpServerStop) error
设置回调函数 - 停止通知
func (*BTcpServer) SetLocalAddr ¶
func (t *BTcpServer) SetLocalAddr(localip string, localport int) error
设置本地地址信息
func (*BTcpServer) SetNotifyThread ¶
func (t *BTcpServer) SetNotifyThread(notifythread IBaseThread) error
设置通知协程
type BUdp ¶
type BUdp struct {
// contains filtered or unexported fields
}
=================udp节点
func (*BUdp) GetLocalAddr ¶
func (*BUdp) GetPacketSize ¶
func (*BUdp) GetRemoteAddr ¶
func (*BUdp) SendDataTo ¶
func (*BUdp) SetFnUdpRcvData ¶
func (t *BUdp) SetFnUdpRcvData(fnrecv FnUdpRcvData) error
设置回调函数 - 收到数据通知
func (*BUdp) SetLocalAddr ¶
设置本地地址信息
func (*BUdp) SetNotifyThread ¶
func (t *BUdp) SetNotifyThread(notifythread IBaseThread) error
设置通知协程
func (*BUdp) SetRemoteAddr ¶
设置远端地址信息
type BaseTcpClient ¶
type BaseTcpClient struct {
// contains filtered or unexported fields
}
func NewBaseTcpClient ¶
func NewBaseTcpClient(classid uint32, packetsize int) *BaseTcpClient
新构建一个TcpClient
func (*BaseTcpClient) AddTcpClient ¶
func (t *BaseTcpClient) AddTcpClient(clientid uint32, localip string, localport int, remoteip string, remoteport int) error
添加一个UDP
func (*BaseTcpClient) AddTcpClientWithCallback ¶
func (t *BaseTcpClient) AddTcpClientWithCallback(clientid uint32, localip string, localport int, remoteip string, remoteport int, notifythread IBaseThread, fnconn FnTcpClientConn, fndisconn FnTcpClientDisConn, fnrcvdata FnTcpClientRcvData) error
func (*BaseTcpClient) DelTcpClient ¶
func (t *BaseTcpClient) DelTcpClient(clientid uint32) error
删除一个UDP
func (*BaseTcpClient) FreeBs ¶
func (t *BaseTcpClient) FreeBs(bs []byte) error
将申请通知使用的缓存还回缓冲池,提高使用率
func (*BaseTcpClient) GetTcpClientInfo ¶
func (t *BaseTcpClient) GetTcpClientInfo(clientid uint32) (bool, *time.Time, string, int, string, int, error)
获取指定编号tcpclient是否已经启动,以及本地地址和端口
func (*BaseTcpClient) SendData ¶
func (t *BaseTcpClient) SendData(clientid uint32, bs []byte) (int, error)
发送数据
func (*BaseTcpClient) SetFnTcpClientConn ¶
func (t *BaseTcpClient) SetFnTcpClientConn(fntcpclientconn FnTcpClientConn) error
设置默认回调-启动 对于已经启动的TcpClient,不受影响
func (*BaseTcpClient) SetFnTcpClientDisConn ¶
func (t *BaseTcpClient) SetFnTcpClientDisConn(fntcpclientdisconn FnTcpClientDisConn) error
设置默认回调-停止 对于已经启动的TcpClient,不受影响
func (*BaseTcpClient) SetFnTcpClientRcvData ¶
func (t *BaseTcpClient) SetFnTcpClientRcvData(fntcpclientrcvdata FnTcpClientRcvData) error
设置默认回调-收到数据 对于已经启动的TcpClient,不受影响
func (*BaseTcpClient) SetNotifyThread ¶
func (t *BaseTcpClient) SetNotifyThread(notifythread IBaseThread) error
设置默认通知线程 对于已经启动的TcpClient,不受影响
func (*BaseTcpClient) StartTcpClient ¶
func (t *BaseTcpClient) StartTcpClient(clientid uint32) error
启动一个UDP
func (*BaseTcpClient) StopTcpClient ¶
func (t *BaseTcpClient) StopTcpClient(clientid uint32) error
停止一个UDP
type BaseThread ¶
=======================================================================================
func (*BaseThread) Init ¶
func (t *BaseThread) Init() int
func (*BaseThread) InitilizeThread ¶
func (t *BaseThread) InitilizeThread(classId uint32, name string, fnInit FnInit, fnUnInit FnUnInit, fnDoWithMsg FnDoWithMsg) error
* 新创建一个线程对象
func (*BaseThread) IsStart ¶
func (t *BaseThread) IsStart() bool
func (*BaseThread) PostComplexMsg ¶
func (*BaseThread) PostMsg ¶
func (t *BaseThread) PostMsg(msgId uint32, wParam uint64, lParam uint64) error
func (*BaseThread) Start ¶
func (t *BaseThread) Start() error
func (*BaseThread) Stop ¶
func (t *BaseThread) Stop() error
func (*BaseThread) UnInit ¶
func (t *BaseThread) UnInit() int
func (*BaseThread) WaitExit ¶
func (t *BaseThread) WaitExit() error
type BaseTimer ¶
type BaseTimer struct {
// contains filtered or unexported fields
}
基本定时器
func (*BaseTimer) AddCronTimer ¶
func (t *BaseTimer) AddCronTimer(timerid uint32, cron string, param uint64, info string, notifythread IBaseThread, fnontimer FnOnTimer) error
添加CRON定时器 cron (second,1)|second|minute|hour|day|month|year|week
func (*BaseTimer) AddCycleTimer ¶
func (t *BaseTimer) AddCycleTimer(timerid uint32, timerlen int, param uint64, info string, notifythread IBaseThread, fnontimer FnOnTimer) error
添加循环定时器
func (*BaseTimer) AddOnceTimer ¶
func (t *BaseTimer) AddOnceTimer(timerid uint32, timerlen int, param uint64, info string, notifythread IBaseThread, fnontimer FnOnTimer) error
添加单次定时器
type BaseUdp ¶
type BaseUdp struct {
// contains filtered or unexported fields
}
func (*BaseUdp) AddUdpWithCallback ¶
func (t *BaseUdp) AddUdpWithCallback(udpid uint32, localip string, localport int, notifythread IBaseThread, fnstart FnUdpStart, fnstop FnUdpStop, fnrcvdata FnUdpRcvData) error
func (*BaseUdp) GetUdpInfo ¶
获取指定编号udp是否已经启动,以及本地地址和端口
func (*BaseUdp) SetFnUdpRcvData ¶
func (t *BaseUdp) SetFnUdpRcvData(fnduprcvdata FnUdpRcvData) error
设置默认回调-收到数据 对于已经启动的UDP,不受影响
func (*BaseUdp) SetFnUdpStart ¶
func (t *BaseUdp) SetFnUdpStart(fnudpstart FnUdpStart) error
设置默认回调-启动 对于已经启动的UDP,不受影响
func (*BaseUdp) SetFnUdpStop ¶
设置默认回调-停止 对于已经启动的UDP,不受影响
func (*BaseUdp) SetNotifyThread ¶
func (t *BaseUdp) SetNotifyThread(notifythread IBaseThread) error
设置默认通知线程 对于已经启动的UDP,不受影响
type BytebufferPool ¶
type BytebufferPool struct {
// contains filtered or unexported fields
}
=====================================================================================
func NewBytebufferPool ¶
func NewBytebufferPool(size int) *BytebufferPool
func (*BytebufferPool) GetBytebuffer ¶
func (t *BytebufferPool) GetBytebuffer() []byte
func (*BytebufferPool) PutBytebuffer ¶
func (t *BytebufferPool) PutBytebuffer(b []byte)
type FnDoWithMsg ¶
type FnDoWithMsg func(classId uint32, msgId uint32, wParam uint64, lParam uint64, wInfo string, lInfo string, otherInfo interface{}) int
线程消息处理函数,返回0退出线程
type FnTcpClientConn ¶
type FnTcpClientConn func(classId uint32, clientId uint32, localIp string, localPort int, remoteIp string, remotePort int)
tcpclient
type FnTcpClientDisConn ¶
type FnTcpClientRcvData ¶
type FnTcpServerConn ¶
type FnTcpServerDisConn ¶
type FnTcpServerRcvData ¶
type FnTcpServerStart ¶
tcpserver
type FnTcpServerStop ¶
type FnUdpRcvData ¶
type FnUdpStart ¶
UDP处理回调函数
type IBaseThread ¶
type IBaseThread interface { //初始化线程 InitilizeThread(classId uint32, name string, fnInit FnInit, fnUnInit FnUnInit, fnDoWithMsg FnDoWithMsg) error //查看线程是否已经启动 IsStart() bool //启动线程 Start() error //停止线程 Stop() error //等待线程退出 WaitExit() error //Post一个简单消息 PostMsg(msgId uint32, wParam uint64, lParam uint64) error //post一个带参数的消息 PostComplexMsg(classId uint32, msgId uint32, wParam uint64, lParam uint64, wInfo string, lInfo string, otherInfo interface{}) error //线程启动初始化 Init() int //线程退出自动执行 UnInit() int //线程消息处理函数 DoWithMsg(classId uint32, msgId uint32, wParam uint64, lParam uint64, wInfo string, lInfo string, otherInfo interface{}) int }
type TMemStream ¶
type TMemStream struct {
// contains filtered or unexported fields
}
func (*TMemStream) Append ¶
func (t *TMemStream) Append(bs []byte)
func (*TMemStream) Clear ¶
func (t *TMemStream) Clear()
func (*TMemStream) GetAndRemove ¶
func (t *TMemStream) GetAndRemove(l int) []byte
func (*TMemStream) GetHead ¶
func (t *TMemStream) GetHead(l int) []byte