gnet

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2025 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(addr string, chRecv chan []interface{}) *Client

func (*Client) Close

func (c *Client) Close()

func (*Client) Send

func (c *Client) Send(msg IMsg)

type CodecDefault

type CodecDefault struct {
	// contains filtered or unexported fields
}

func (*CodecDefault) Decode

func (c *CodecDefault) Decode(data []byte) []byte

func (*CodecDefault) Encode

func (c *CodecDefault) Encode(data []byte) []byte

func (*CodecDefault) Read

func (c *CodecDefault) Read(con net.Conn) ([]byte, error)

func (*CodecDefault) Write

func (c *CodecDefault) Write(con net.Conn, data []byte) (int, error)

type ICodec

type ICodec interface {
	Encode([]byte) []byte
	Decode([]byte) []byte
	//
	Read(net.Conn) ([]byte, error)
	Write(net.Conn, []byte) (int, error)
}

func NewCodec

func NewCodec(codecType int, maxPacketSize int) ICodec

type IConnection

type IConnection interface {
	GetCID() int32
	GetSendChan() chan interface{}
	Close()
}

func NewConnection

func NewConnection(cid int32, con net.Conn, codec ICodec, ctx context.Context, chSend chan interface{}, chRecv chan []interface{}) IConnection

type IMsg

type IMsg interface {
	MsgID() int32
	Body() []byte

	SetMsgID(int32)
	SetBody([]byte)

	Marshal() []byte
	Unmarshal(data []byte) IMsg
}

func NewMsg

func NewMsg() IMsg

type Server

type Server struct {
	// contains filtered or unexported fields
}

func (*Server) Close

func (s *Server) Close()

func (*Server) GetConnectionInfo

func (s *Server) GetConnectionInfo(cid int32) (map[string]string, error)

func (*Server) SendMsg

func (s *Server) SendMsg(cid int32, msg IMsg) error

func (*Server) Start

func (s *Server) Start(ip string, port int, codecType int, maxPacketSize int, chRecv chan []interface{})

Jump to

Keyboard shortcuts

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