Documentation ¶
Index ¶
- type Client
- type Handle
- type OnAuthenticationHandler
- type OnConnectHandler
- type OnDataHandler
- type OnDisconnectHandler
- type Options
- func (o *Options) SetAddress(address string) *Options
- func (o *Options) SetAuthenticationEnable(authenticationEnable bool) *Options
- func (o *Options) SetAuthenticationFailedCap(cap int) *Options
- func (o *Options) SetBlacklistDuration(duration int64) *Options
- func (o *Options) SetClientConnectCap(cap int) *Options
- func (o *Options) SetClientSameIPCap(cap int) *Options
- func (o *Options) SetOnAuthenticationHandler(onAuth OnAuthenticationHandler) *Options
- func (o *Options) SetOnConnectHandler(onConn OnConnectHandler) *Options
- func (o *Options) SetOnDataHandler(onData OnDataHandler) *Options
- func (o *Options) SetOnDisconnectHandler(onLost OnDisconnectHandler) *Options
- type UdpClient
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Handle ¶
type Handle interface { Send(key string, data []byte) error GetClient(key string) *Client RemoveClientFromBlacklist(key string) error CloseClient(key string) error CloseAllClient() error ClientList() []*Client Run() error }
Handle 接口
type OnAuthenticationHandler ¶
type OnAuthenticationHandler func(Handle, define.AgreementData) bool
OnAuthenticationHandler 认证回调函数
type OnConnectHandler ¶
OnConnectHandler 客户端连接成功后的回调函数
type OnDataHandler ¶
OnDataHandler 客户端收到数据后的回调函数
type OnDisconnectHandler ¶
OnDisconnectHandler 客户端断开后的回调函数
type Options ¶
type Options struct { Address string `json:"address"` KeepAlive time.Duration `json:"keepalive"` AuthenticationEnable bool `json:"authenticationEnable"` ClientConnectCap int `json:"clientConnectCap"` ClientSameIPCap int `json:"clientSameIPCap"` BlacklistDuration int64 `json:"blacklistDuration"` AuthenticationFailedCap int `json:"authenticationFailedCap"` OnConnect OnConnectHandler OnDisconnect OnDisconnectHandler OnData OnDataHandler OnAuthentication OnAuthenticationHandler }
func (*Options) SetAddress ¶
SetAddress sets the address to be used by the client to connect.
func (*Options) SetAuthenticationEnable ¶
SetAuthenticationEnable sets the function to be called when the client connected and for the first time receives data.
func (*Options) SetAuthenticationFailedCap ¶
SetAuthenticationFailedCap sets the maximum number of authentication failures.
func (*Options) SetBlacklistDuration ¶
SetBlacklistDuration sets the duration of the blacklist.
func (*Options) SetClientConnectCap ¶
SetClientConnectCap sets the maximum number of concurrent connections.
func (*Options) SetClientSameIPCap ¶
SetClientSameIPCap sets the maximum number of concurrent connections from the same IP.
func (*Options) SetOnAuthenticationHandler ¶
func (o *Options) SetOnAuthenticationHandler(onAuth OnAuthenticationHandler) *Options
SetOnAuthenticationHandler sets the function to be called when the client receives data.
func (*Options) SetOnConnectHandler ¶
func (o *Options) SetOnConnectHandler(onConn OnConnectHandler) *Options
SetOnConnectHandler sets the function to be called when the client is connected. Both
func (*Options) SetOnDataHandler ¶
func (o *Options) SetOnDataHandler(onData OnDataHandler) *Options
SetOnDataHandler sets the function to be called when the client receives data.
func (*Options) SetOnDisconnectHandler ¶
func (o *Options) SetOnDisconnectHandler(onLost OnDisconnectHandler) *Options
SetOnDisconnectHandler sets the function to be called when the client is disconnected.