yclient

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	HEART_MSG = "heart_msg"
)

Functions

func NewClient

func NewClient(id string, ip string, port int) *client

Types

type Connection

type Connection struct {
	//当前Conn属于哪个Server
	Client yiface.IClient //当前conn属于哪个server,在conn初始化的时候添加即可
	sync.RWMutex
	//当前连接的套接字
	Conn *net.TCPConn
	//当前连接的ID,也可以作为sessionID,全局唯一
	ConnId uint32

	//消息管理MsgId和对应处理方法的消息管理模块
	MsgHandler yiface.IMsgHandle
	// contains filtered or unexported fields
}

func NewConnection

func NewConnection(client yiface.IClient, conn *net.TCPConn, handle yiface.IMsgHandle) *Connection

func (*Connection) GetConnId

func (c *Connection) GetConnId() uint32

func (*Connection) GetProperty

func (c *Connection) GetProperty(key string) (interface{}, error)

func (*Connection) GetTCPConnection

func (c *Connection) GetTCPConnection() *net.TCPConn

func (*Connection) RemoteAddr

func (c *Connection) RemoteAddr() net.Addr

func (*Connection) RemoveProperty

func (c *Connection) RemoveProperty(key string)

func (*Connection) SendBuffMsg

func (c *Connection) SendBuffMsg(msgId uint32, data []byte) error

func (*Connection) SendMsg

func (c *Connection) SendMsg(msgId uint32, data []byte) error

func (*Connection) SetProperty

func (c *Connection) SetProperty(key string, value interface{})

func (*Connection) Start

func (c *Connection) Start()

func (*Connection) StartReader

func (c *Connection) StartReader()

处理conn读数据的Goroutine

func (*Connection) Stop

func (c *Connection) Stop()

Jump to

Keyboard shortcuts

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