Versions in this module Expand all Collapse all v1 v1.0.0 Jan 2, 2024 Changes in this version + const CtxKey_Text + const CtxKey_WS + var ParamConf loader.JsonLoader[ParamConfig] + var WSHeader = http.Header + type ClientCreater interface + ClientCreate func() + type ClientNamer interface + ClientName func() string + type ParamConfig struct + ActiveTimeout int + IgnoreIp []string + LogLevelByMsg map[string]int + LogLevelMsg int + MsgSeq bool + WSHeader map[string][]string + func (c *ParamConfig) Create() + func (c *ParamConfig) IsIgnoreIp(ip string) bool + func (c *ParamConfig) MsgLogLevel(msgid string) int + func (c *ParamConfig) Normalize() + type TCPClient struct + func (tc *TCPClient[ClientInfo]) Close(err error) + func (tc *TCPClient[ClientInfo]) CloseWait(err error) + func (tc *TCPClient[ClientInfo]) ConnName() string + func (tc *TCPClient[ClientInfo]) Info() *ClientInfo + func (tc *TCPClient[ClientInfo]) LocalAddr() string + func (tc *TCPClient[ClientInfo]) RemoteAddr() string + func (tc *TCPClient[ClientInfo]) Send(ctx context.Context, data []byte) error + func (tc *TCPClient[ClientInfo]) SendMsg(ctx context.Context, msg utils.SendMsger) error + func (tc *TCPClient[ClientInfo]) SendRPCMsg(ctx context.Context, rpcId interface{}, msg utils.SendMsger, ...) (interface{}, error) + func (tc *TCPClient[ClientInfo]) SendText(ctx context.Context, data []byte) error + type TCPEvent interface + CheckRPCResp func(msg interface{}) interface{} + Context func(parent context.Context, msg interface{}) context.Context + DecodeMsg func(ctx context.Context, data []byte, tc *TCPClient[ClientInfo]) (interface{}, int, error) + OnConnected func(ctx context.Context, tc *TCPClient[ClientInfo]) + OnDisConnect func(ctx context.Context, tc *TCPClient[ClientInfo]) + OnMsg func(ctx context.Context, msg interface{}, tc *TCPClient[ClientInfo]) + OnTick func(ctx context.Context, tc *TCPClient[ClientInfo]) + type TCPEventHandler struct + func (*TCPEventHandler[ClientInfo]) CheckRPCResp(msg interface{}) interface{} + func (*TCPEventHandler[ClientInfo]) DecodeMsg(ctx context.Context, data []byte, tc *TCPClient[ClientInfo]) (interface{}, int, error) + func (*TCPEventHandler[ClientInfo]) OnConnected(ctx context.Context, tc *TCPClient[ClientInfo]) + func (*TCPEventHandler[ClientInfo]) OnDisConnect(ctx context.Context, tc *TCPClient[ClientInfo]) + func (*TCPEventHandler[ClientInfo]) OnMsg(ctx context.Context, msg interface{}, tc *TCPClient[ClientInfo]) + func (*TCPEventHandler[ClientInfo]) OnTick(ctx context.Context, tc *TCPClient[ClientInfo]) + func (h *TCPEventHandler[ClientInfo]) Context(parent context.Context, msg interface{}) context.Context + type TCPHook interface + OnAddClient func(tc *TCPClient[ClientInfo]) + OnConnected func(tc *TCPClient[ClientInfo]) + OnDisConnect func(tc *TCPClient[ClientInfo], removeClient bool, closeReason error) + OnRecv func(tc *TCPClient[ClientInfo], len int) + OnRemoveClient func(tc *TCPClient[ClientInfo]) + OnSend func(tc *TCPClient[ClientInfo], len int) + OnWSHandShake func(gc *TCPClient[ClientInfo]) + type TCPServer struct + Address string + Scheme string + func NewTCPServerWithWS2[ClientId any, ClientInfo any](port int, event TCPEvent[ClientInfo], certPEMBlock, keyPEMBlock []byte) (*TCPServer[ClientId, ClientInfo], error) + func NewTCPServerWithWS[ClientId any, ClientInfo any](port int, event TCPEvent[ClientInfo], certFile, keyFile string) (*TCPServer[ClientId, ClientInfo], error) + func NewTCPServer[ClientId any, ClientInfo any](port int, event TCPEvent[ClientInfo]) (*TCPServer[ClientId, ClientInfo], error) + func (s *TCPServer[ClientId, ClientInfo]) AddClient(id ClientId, tc *TCPClient[ClientInfo]) + func (s *TCPServer[ClientId, ClientInfo]) ClientCount() int + func (s *TCPServer[ClientId, ClientInfo]) CloseClient(id ClientId) + func (s *TCPServer[ClientId, ClientInfo]) ConnCount() (int, int) + func (s *TCPServer[ClientId, ClientInfo]) GetClient(id ClientId) *TCPClient[ClientInfo] + func (s *TCPServer[ClientId, ClientInfo]) OnAccept(c net.Conn) + func (s *TCPServer[ClientId, ClientInfo]) OnClose(c *tcp.TCPConn) + func (s *TCPServer[ClientId, ClientInfo]) OnDisConnect(err error, c *tcp.TCPConn) error + func (s *TCPServer[ClientId, ClientInfo]) OnRecv(data []byte, c *tcp.TCPConn) (int, error) + func (s *TCPServer[ClientId, ClientInfo]) OnSend(data []byte, c *tcp.TCPConn) ([]byte, error) + func (s *TCPServer[ClientId, ClientInfo]) OnShutdown() + func (s *TCPServer[ClientId, ClientInfo]) RangeClient(f func(tc *TCPClient[ClientInfo]) bool) + func (s *TCPServer[ClientId, ClientInfo]) RegHook(h TCPHook[ClientInfo]) + func (s *TCPServer[ClientId, ClientInfo]) RemoveClient(id ClientId) *TCPClient[ClientInfo] + func (s *TCPServer[ClientId, ClientInfo]) Send(ctx context.Context, id ClientId, data []byte) error + func (s *TCPServer[ClientId, ClientInfo]) SendMsg(ctx context.Context, id ClientId, msg utils.SendMsger) error + func (s *TCPServer[ClientId, ClientInfo]) Start(reusePort bool) error + func (s *TCPServer[ClientId, ClientInfo]) Stop() error