tcp

package
v1.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 8, 2021 License: Apache-2.0 Imports: 10 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewClient

func NewClient(server agent.Server, conn net.Conn, ip string) agent.Client

实例化新的客户端连接

func NewServer

func NewServer(agent *agent.Agent) agent.Server

Types

type Client

type Client struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func (*Client) Close

func (c *Client) Close()

关闭连接

func (*Client) Closed

func (c *Client) Closed() bool

判断是否关闭

func (*Client) Destroy

func (c *Client) Destroy()

销毁连接 (丢弃任何未发送或未确认的数据)

func (*Client) Id

func (c *Client) Id() string

获取Client ID

func (*Client) Log

func (c *Client) Log() *logger.Helper

日志对象

func (*Client) Meta

func (c *Client) Meta() *agent.Meta

获取客户端元数据

func (*Client) Read

func (c *Client) Read() (*codec.ClientHead, []byte, error)

发送消息

func (*Client) Server

func (c *Client) Server() agent.Server

获取关联服务端

func (*Client) SetAuthState

func (c *Client) SetAuthState(state bool)

认证成功

func (*Client) Write

func (c *Client) Write(b []byte)

发送消息

type Server

type Server struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func (*Server) Agent

func (s *Server) Agent() *agent.Agent

Agent 网关对象

func (*Server) Close

func (s *Server) Close()

关闭

func (*Server) Name

func (s *Server) Name() string

Name 服务器名称

func (*Server) Opts

func (s *Server) Opts() *agent.Options

Opts 网关参数

func (*Server) Port

func (s *Server) Port() int

Port 监听端口

func (*Server) Run

func (s *Server) Run() error

启动

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL