network

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: May 31, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NEW_CONNECTION = iota
	WORKING
	CLOSING
	CLOSED
)
View Source
const (
	PKG_TYPE = iota
	HEARTBEAT
	HEARTBEAT_RET
	DATA
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Data

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

type Handler

type Handler interface {
	Connect(uint16, *Session)
	Message(uint16, uint16, []byte)
	Heartbeat(uint16, uint16)
	Close(uint16)
}

type Session

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

func CreateSession

func CreateSession(conn io.ReadWriteCloser, msgHandle func(uint16, uint16, []byte)) *Session

func (*Session) Close

func (this *Session) Close()

func (*Session) Forward

func (this *Session) Forward(msgHandle func(uint16, uint16, []byte))

func (*Session) Reader

func (this *Session) Reader() (err error)

func (*Session) Release

func (this *Session) Release()

func (*Session) Start

func (this *Session) Start()

type TcpClient

type TcpClient struct {
	TcpConn
	// contains filtered or unexported fields
}

func NewTcpClient

func NewTcpClient(handle Handler) *TcpClient

func (*TcpClient) Close

func (this *TcpClient) Close()

func (*TcpClient) Dial

func (this *TcpClient) Dial(addr string)

func (*TcpClient) GetSessionID

func (this *TcpClient) GetSessionID() uint16

func (*TcpClient) WriteData

func (this *TcpClient) WriteData(s *Session, buff []byte) uint16

type TcpConn

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

func (*TcpConn) Close

func (this *TcpConn) Close(s *Session)

func (*TcpConn) NewSession

func (this *TcpConn) NewSession(conn net.Conn) *Session

func (*TcpConn) Write

func (this *TcpConn) Write(s *Session, sID uint16, buff []byte)

type TcpServer

type TcpServer struct {
	TcpConn
	// contains filtered or unexported fields
}

func NewTcpServer

func NewTcpServer(handle Handler, addr string) *TcpServer

func (*TcpServer) Start

func (this *TcpServer) Start()

Jump to

Keyboard shortcuts

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