Documentation ¶
Index ¶
- Constants
- Variables
- type KcpClient
- func (tc *KcpClient) Close(brokenType int)
- func (tc *KcpClient) CloseCallBack()
- func (tc *KcpClient) Dispatch(data []byte)
- func (tc *KcpClient) NetType() string
- func (tc *KcpClient) Read(p []byte) (int, error)
- func (tc *KcpClient) ReadPack() ([]byte, error)
- func (tc *KcpClient) Start()
- func (tc *KcpClient) Write(data []byte) (int, error)
- type KcpLink
- func (tl *KcpLink) Close(brokenType int)
- func (tl *KcpLink) CloseCallBack()
- func (tl *KcpLink) ID() uint
- func (tl *KcpLink) MsgCount() uint64
- func (tl *KcpLink) NetType() string
- func (tl *KcpLink) Read(p []byte) (int, error)
- func (tl *KcpLink) ReadPack() ([]byte, error)
- func (tl *KcpLink) Start()
- func (tl *KcpLink) Write(data []byte) (int, error)
- type KcpListenServer
- func (b KcpListenServer) AddLink(linkObj Link)
- func (b KcpListenServer) Close()
- func (b KcpListenServer) CloseCallBack()
- func (b KcpListenServer) CloseLink(linkObj Link, brokenType int)
- func (b KcpListenServer) CloseLinkByID(id uint, brokenType int)
- func (b KcpListenServer) Ctx() context.Context
- func (b KcpListenServer) DelLink(linkObj Link, brokenType int)
- func (b KcpListenServer) Dispatch(id uint, bs []byte)
- func (b KcpListenServer) GetLink(id uint) Link
- func (b KcpListenServer) GetListen() net.Listener
- func (b KcpListenServer) LinkCount() int
- func (b KcpListenServer) NetType() string
- func (b KcpListenServer) SendData(id uint, data []byte)
- func (t *KcpListenServer) Start()
- type Link
- type ListenServer
- type TcpClient
- func (tc *TcpClient) Close(brokenType int)
- func (tc *TcpClient) CloseCallBack()
- func (tc *TcpClient) Dispatch(data []byte)
- func (tc *TcpClient) NetType() string
- func (tc *TcpClient) Read(p []byte) (int, error)
- func (tc *TcpClient) ReadPack() ([]byte, error)
- func (tc *TcpClient) Start()
- func (tc *TcpClient) Write(data []byte) (int, error)
- type TcpLink
- func (tl *TcpLink) Close(brokenType int)
- func (tl *TcpLink) CloseCallBack()
- func (tl *TcpLink) ID() uint
- func (tl *TcpLink) MsgCount() uint64
- func (tl *TcpLink) NetType() string
- func (tl *TcpLink) Read(p []byte) (int, error)
- func (tl *TcpLink) ReadPack() ([]byte, error)
- func (tl *TcpLink) Start()
- func (tl *TcpLink) Write(data []byte) (int, error)
- type TcpListenServer
- func (b TcpListenServer) AddLink(linkObj Link)
- func (b TcpListenServer) Close()
- func (b TcpListenServer) CloseCallBack()
- func (b TcpListenServer) CloseLink(linkObj Link, brokenType int)
- func (b TcpListenServer) CloseLinkByID(id uint, brokenType int)
- func (b TcpListenServer) Ctx() context.Context
- func (b TcpListenServer) DelLink(linkObj Link, brokenType int)
- func (b TcpListenServer) Dispatch(id uint, bs []byte)
- func (b TcpListenServer) GetLink(id uint) Link
- func (b TcpListenServer) GetListen() net.Listener
- func (b TcpListenServer) LinkCount() int
- func (b TcpListenServer) NetType() string
- func (b TcpListenServer) SendData(id uint, data []byte)
- func (t *TcpListenServer) Start()
- type WebSocketClient
- func (wc *WebSocketClient) Close(brokenType int)
- func (wc *WebSocketClient) CloseCallBack()
- func (wc *WebSocketClient) Dispatch(data []byte)
- func (wc *WebSocketClient) NetType() string
- func (wc *WebSocketClient) ReadPack() ([]byte, error)
- func (wc *WebSocketClient) Start()
- func (wc *WebSocketClient) Write(data []byte) (int, error)
- type WebSocketLink
- func (wl *WebSocketLink) Close(brokenType int)
- func (wl *WebSocketLink) CloseCallBack()
- func (wl *WebSocketLink) ID() uint
- func (wl *WebSocketLink) MsgCount() uint64
- func (wl *WebSocketLink) NetType() string
- func (wl *WebSocketLink) ReadPack() ([]byte, error)
- func (wl *WebSocketLink) Start()
- func (wl *WebSocketLink) Write(data []byte) (int, error)
- type WebSocketListenServer
- func (b WebSocketListenServer) AddLink(linkObj Link)
- func (b WebSocketListenServer) Close()
- func (b WebSocketListenServer) CloseCallBack()
- func (b WebSocketListenServer) CloseLink(linkObj Link, brokenType int)
- func (b WebSocketListenServer) CloseLinkByID(id uint, brokenType int)
- func (b WebSocketListenServer) Ctx() context.Context
- func (b WebSocketListenServer) DelLink(linkObj Link, brokenType int)
- func (b WebSocketListenServer) Dispatch(id uint, bs []byte)
- func (b WebSocketListenServer) GetLink(id uint) Link
- func (b WebSocketListenServer) GetListen() net.Listener
- func (b WebSocketListenServer) LinkCount() int
- func (b WebSocketListenServer) NetType() string
- func (b WebSocketListenServer) SendData(id uint, data []byte)
- func (w *WebSocketListenServer) Start()
Constants ¶
View Source
const ( NetTypeTcp = "tcp" NetTypeWebSocket = "webSocket" // todo udp NetTypeKcp = "kcp" // todo kcp )
View Source
const (
DisConnectTypeBroken = 0 // 默认网络断开
)
Variables ¶
View Source
var ( // tcp监听地址错误 ErrListenAddrError = errors.TempErr("ListenAddr netType[%s] addr[%s] err : %s") // tcp监听创建监听错误 ErrCreateListenError = errors.TempErr("Create listen netType[%s] addr[%s] err : %s") // 链接读超时 ErrTcpLinkReadTimeOutError = errors.TempErr("Tcp link read tyimeout") /* 断开链接 */ ErrLinkDisconnect = errors.TempErr("broken link: netType:%s brokenType:%d") /* webSocket */ ErrWsRouting = errors.TempErr("web socket route[%v] err: %s") )
Functions ¶
This section is empty.
Types ¶
type KcpListenServer ¶
type KcpListenServer struct {
// contains filtered or unexported fields
}
KcpListenServer tcp服务
func NewKcpListenServer ¶
func (KcpListenServer) CloseCallBack ¶
func (b KcpListenServer) CloseCallBack()
func (KcpListenServer) CloseLinkByID ¶
func (*KcpListenServer) Start ¶
func (t *KcpListenServer) Start()
type ListenServer ¶
type ListenServer interface { Ctx() context.Context // 获取ctx GetListen() net.Listener // 获取底层监听器 NetType() string // 获取网络类型(tcp等) CloseCallBack() // 关闭回调 /* 管理 */ AddLink(linkObj Link) // 添加链接 GetLink(id uint) Link // 获取链接 DelLink(linkObj Link, brokenType int) // 删除链接 CloseLink(linkObj Link, brokenType int) // 关闭链接:先关闭后删除 CloseLinkByID(id uint, brokenType int) // 关闭链接(id索引):先关闭后删除 Dispatch(id uint, bs []byte) // 数据派发 LinkCount() int // 当前拥有的链接数量 SendData(id uint, data []byte) // 发送数据 /* 服务 */ Start() Close() }
type TcpListenServer ¶
type TcpListenServer struct {
// contains filtered or unexported fields
}
TcpListenServer tcp服务
func NewTcpListenServer ¶
func (TcpListenServer) CloseCallBack ¶
func (b TcpListenServer) CloseCallBack()
func (TcpListenServer) CloseLinkByID ¶
func (*TcpListenServer) Start ¶
func (t *TcpListenServer) Start()
type WebSocketClient ¶
type WebSocketClient struct {
// contains filtered or unexported fields
}
func NewWebScoketClient ¶
func NewWebScoketClient(parent context.Context, host, routing string) (*WebSocketClient, error)
func (*WebSocketClient) CloseCallBack ¶
func (wc *WebSocketClient) CloseCallBack()
CloseCallBack 关闭回调
func (*WebSocketClient) Dispatch ¶
func (wc *WebSocketClient) Dispatch(data []byte)
func (*WebSocketClient) NetType ¶
func (wc *WebSocketClient) NetType() string
func (*WebSocketClient) ReadPack ¶
func (wc *WebSocketClient) ReadPack() ([]byte, error)
ReadPack 读取数据包
func (*WebSocketClient) Start ¶
func (wc *WebSocketClient) Start()
type WebSocketLink ¶
type WebSocketLink struct {
// contains filtered or unexported fields
}
func NewWebSocketLink ¶
func NewWebSocketLink(parent context.Context, fd *websocket.Conn, listenServer ListenServer) *WebSocketLink
func (*WebSocketLink) MsgCount ¶
func (wl *WebSocketLink) MsgCount() uint64
func (*WebSocketLink) Start ¶
func (wl *WebSocketLink) Start()
type WebSocketListenServer ¶
type WebSocketListenServer struct {
// contains filtered or unexported fields
}
WebSocketListenServer webSocket服务
func (WebSocketListenServer) CloseCallBack ¶
func (b WebSocketListenServer) CloseCallBack()
func (WebSocketListenServer) CloseLinkByID ¶
func (*WebSocketListenServer) Start ¶
func (w *WebSocketListenServer) Start()
Source Files ¶
Click to show internal directories.
Click to hide internal directories.