Documentation ¶
Index ¶
Constants ¶
View Source
const (
//PackageLengthSize package length size
PackageLengthSize = 2
)
Variables ¶
View Source
var ErrReadMessage = errors.New("read message failed")
ErrReadMessage read message failed
View Source
var ErrReadPackageLength = errors.New("read package length failed")
ErrReadPackageLength read package length failed
Functions ¶
func NewConn ¶
func NewConn(conn net.Conn, rwQueueSize int, maxMessageSize uint32, readDeadline time.Duration) network.IConn
NewConn create kcp conn
func NewServer ¶
func NewServer(conf config.IConfig, agentFunc network.AgentCreateFunc, agentCloseFunc network.AgentCloseFunc) network.IServer
NewServer create kcp server
Types ¶
type Client ¶
type Client struct { sync.Mutex Conf *ClientConfig NewAgent network.AgentCreateFunc CloseAgent network.AgentCloseFunc // contains filtered or unexported fields }
Client kcp client
func NewClient ¶
func NewClient(conf config.IConfig, agentFunc network.AgentCreateFunc, agentCloseFunc network.AgentCloseFunc) *Client
NewClient create kcp client
type ClientConfig ¶
type ClientConfig struct { Nodes []common.NodeInfo `mapstructure:"nodes"` ConnNum int `mapstructure:"conn_num"` ConnectInterval time.Duration `mapstructure:"connect_interval"` SocketQueueSize int `mapstructure:"socket_queue_size"` MaxMessageSize uint32 `mapstructure:"max_message_size"` HandshakeTimeout time.Duration `mapstructure:"handshake_timeout"` AutoReconnect bool `mapstructure:"auto_reconnect"` UDPSocketBufferSize int `mapstructure:"udp_socket_buffer_size"` //UDP listener socket buffer Dscp int `mapstructure:"dscp"` //set DSCP(6bit) Sndwnd int `mapstructure:"sndwnd"` //per connection UDP send window Rcvwnd int `mapstructure:"rcvwnd"` //per connection UDP recv window Mtu int `mapstructure:"mtu"` //MTU of UDP packets, without IP(20) + UDP(8) Nodelay int `mapstructure:"nodelay"` //ikcp_nodelay() Interval int `mapstructure:"interval"` //ikcp_nodelay() Resend int `mapstructure:"resend"` //ikcp_nodelay() Nc int `mapstructure:"nc"` //ikcp_nodelay() ReadDeadline time.Duration `mapstructure:"read_dead_line"` QueueSize int `mapstructure:"queue_size"` }
ClientConfig grpc client config
func (*ClientConfig) GetQueueSize ¶
func (c *ClientConfig) GetQueueSize() int
GetQueueSize get module queue size
type Config ¶
type Config struct { Address string MaxConnNum int RWQueueSize int MaxMessageSize uint32 UDPSocketBufferSize int //UDP listener socket buffer ReadDeadline time.Duration // contains filtered or unexported fields }
Config kcp conn config
type Conn ¶
Conn kcp conn define
func (*Conn) ReadMessage ¶
ReadMessage goroutine not safe
func (*Conn) WriteMessage ¶
WriteMessage args must not be modified by the others goroutines buffer must packet with 2B package length
type Server ¶
type Server struct { Conf *ServerConfig NewAgent network.AgentCreateFunc CloseAgent network.AgentCloseFunc // contains filtered or unexported fields }
Server kcp server define
type ServerConfig ¶
type ServerConfig struct { Address string `mapstructure:"address"` MaxConnNum int `mapstructure:"max_conn_num"` SocketQueueSize int `mapstructure:"socket_queue_size"` MaxMessageSize uint32 `mapstructure:"max_message_size"` UDPSocketBufferSize int `mapstructure:"udp_socket_buffer_size"` //UDP listener socket buffer ReadDeadline time.Duration `mapstructure:"read_dead_line"` Dscp int `mapstructure:"dscp"` //set DSCP(6bit) Sndwnd int `mapstructure:"snd_wnd"` //per connection UDP send window Rcvwnd int `mapstructure:"recv_wnd"` //per connection UDP recv window Mtu int `mapstructure:"mtu"` //MTU of UDP packets, without IP(20) + UDP(8) Nodelay int `mapstructure:"nodelay"` //ikcp_nodelay() Interval int `mapstructure:"interval"` //ikcp_nodelay() Resend int `mapstructure:"resend"` //ikcp_nodelay() Nc int `mapstructure:"nc"` //ikcp_nodelay() QueueSize int `mapstructure:"queue_size"` }
ServerConfig grpc server config
func (*ServerConfig) GetQueueSize ¶
func (s *ServerConfig) GetQueueSize() int
GetQueueSize get module queue size
Click to show internal directories.
Click to hide internal directories.