inet

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2021 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewKcpServer

func NewKcpServer(addr string, processor iduck.Processor) (s *kcpServer, err error)

NewKcpServer return a *kcpServer

func NewQUICServer

func NewQUICServer(addr string, processor iduck.Processor, config *tls.Config) (s *quicServer, err error)

NewQUICServer return new quicServer

func NewTcpServer

func NewTcpServer(addr string, processor iduck.Processor) (s *tcpServer, err error)

NewTcpServer return new tcpServer

func NewWsServer

func NewWsServer(addr string, processor iduck.Processor) (s *wsServer, err error)

NewWsServer return new wsServer

Types

type BroadcastNode

type BroadcastNode struct {
	// 节点ID
	NodeId string
	// 网络连接
	Connections map[interface{}]iduck.IConnection
	// contains filtered or unexported fields
}

BroadcastNode 广播转发节点

func NewBroadcastNode

func NewBroadcastNode() *BroadcastNode

NewBroadcastNode return a new BroadcastNode

func (*BroadcastNode) AddConn

func (bNode *BroadcastNode) AddConn(conn iduck.IConnection) error

AddConn by conn

func (*BroadcastNode) Complete

func (bNode *BroadcastNode) Complete() error

Complete sync

func (*BroadcastNode) DelConn

func (bNode *BroadcastNode) DelConn(key string) error

DelConn by key

func (*BroadcastNode) Destroy

func (bNode *BroadcastNode) Destroy() error

Destroy the node

func (*BroadcastNode) GetAllMessage

func (bNode *BroadcastNode) GetAllMessage() chan []interface{}

GetAllMessage return chan []interface{}

func (*BroadcastNode) OnProtocolMessage

func (bNode *BroadcastNode) OnProtocolMessage(msg interface{}) error

OnProtocolMessage interface

func (*BroadcastNode) OnRawMessage

func (bNode *BroadcastNode) OnRawMessage([]byte) error

OnRawMessage bytes

func (*BroadcastNode) Serve

func (bNode *BroadcastNode) Serve()

Serve the node

type FrameNode

type FrameNode struct {
	// 节点ID
	NodeId string
	// 网络连接
	Connections map[interface{}]iduck.IConnection

	// 同步周期
	FrameTicker *time.Ticker

	// rand seed
	RandSeed int64
	// contains filtered or unexported fields
}

FrameNode 帧同步节点

func NewFrameNode

func NewFrameNode() *FrameNode

NewFrameNode return a new FrameNode

func (*FrameNode) AddConn

func (gr *FrameNode) AddConn(conn iduck.IConnection) error

AddConn conn

func (*FrameNode) Complete

func (gr *FrameNode) Complete() error

Complete sync

func (*FrameNode) DelConn

func (gr *FrameNode) DelConn(key string) error

DelConn by key

func (*FrameNode) Destroy

func (gr *FrameNode) Destroy() error

Destroy the node

func (*FrameNode) GetAllMessage

func (gr *FrameNode) GetAllMessage() chan []interface{}

GetAllMessage return chan []interface

func (*FrameNode) OnProtocolMessage

func (gr *FrameNode) OnProtocolMessage(interface{}) error

OnProtocolMessage interface

func (*FrameNode) OnRawMessage

func (gr *FrameNode) OnRawMessage(msg []byte) error

OnRawMessage msg

func (*FrameNode) Serve

func (gr *FrameNode) Serve()

Serve the node

type KCPConn

type KCPConn struct {
	*TCPConn
}

KCPConn 可靠的UDP,like TCP

func NewKcpConn

func NewKcpConn(conn net.Conn, processor iduck.Processor) *KCPConn

NewKcpConn get new kcp conn

type QuicStream

type QuicStream struct {
	sync.RWMutex

	quic.Stream
	// contains filtered or unexported fields
}

QuicStream is warped udp conn for luck

func NewQuicStream

func NewQuicStream(stream quic.Stream, processor iduck.Processor) *QuicStream

NewQuicStream return new udp conn

func (*QuicStream) AfterClose

func (s *QuicStream) AfterClose(cb func())

AfterClose conn call back

func (*QuicStream) Close

func (s *QuicStream) Close() error

Close the conn

func (*QuicStream) GetData

func (s *QuicStream) GetData() interface{}

GetData from conn

func (*QuicStream) GetNode

func (s *QuicStream) GetNode() iduck.INode

GetNode from conn

func (*QuicStream) GetUuid

func (s *QuicStream) GetUuid() string

GetUuid get uuid of conn

func (*QuicStream) IsClosed

func (s *QuicStream) IsClosed() bool

IsClosed return the status of conn

func (*QuicStream) ReadMsg

func (s *QuicStream) ReadMsg()

ReadMsg read | write end -> write | read end -> conn end

func (*QuicStream) SetData

func (s *QuicStream) SetData(data interface{})

SetData for conn

func (*QuicStream) SetNode

func (s *QuicStream) SetNode(node iduck.INode)

SetNode for conn

func (*QuicStream) WriteMsg

func (s *QuicStream) WriteMsg(message interface{})

WriteMsg warp msg base on conn's processor

type TCPConn

type TCPConn struct {
	sync.RWMutex

	net.Conn
	// contains filtered or unexported fields
}

TCPConn is warped tcp conn for luck

func NewTcpConn

func NewTcpConn(conn net.Conn, processor iduck.Processor) *TCPConn

NewTcpConn return new tcp conn

func (*TCPConn) AfterClose

func (tc *TCPConn) AfterClose(cb func())

AfterClose conn call back

func (*TCPConn) Close

func (tc *TCPConn) Close() error

Close the conn

func (*TCPConn) GetData

func (tc *TCPConn) GetData() interface{}

GetData from conn

func (*TCPConn) GetNode

func (tc *TCPConn) GetNode() iduck.INode

GetNode from conn

func (*TCPConn) GetUuid

func (tc *TCPConn) GetUuid() string

GetUuid get uuid of conn

func (*TCPConn) IsClosed

func (tc *TCPConn) IsClosed() bool

IsClosed return the status of conn

func (*TCPConn) ReadMsg

func (tc *TCPConn) ReadMsg()

ReadMsg read | write end -> write | read end -> conn end

func (*TCPConn) SetData

func (tc *TCPConn) SetData(data interface{})

SetData for conn

func (*TCPConn) SetNode

func (tc *TCPConn) SetNode(node iduck.INode)

SetNode for conn

func (*TCPConn) WriteMsg

func (tc *TCPConn) WriteMsg(message interface{})

WriteMsg warp msg base on conn's processor

type WSConn

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

WSConn is warped tcp conn for luck

func NewWSConn

func NewWSConn(conn *websocket.Conn, processor iduck.Processor) *WSConn

NewWSConn return new ws conn

func (*WSConn) AfterClose

func (wc *WSConn) AfterClose(cb func())

AfterClose conn call back

func (*WSConn) Close

func (wc *WSConn) Close() error

Close the conn

func (*WSConn) GetData

func (wc *WSConn) GetData() interface{}

GetData from conn

func (*WSConn) GetNode

func (wc *WSConn) GetNode() iduck.INode

GetNode from conn

func (*WSConn) GetUuid

func (wc *WSConn) GetUuid() string

GetUuid get uuid of conn

func (*WSConn) IsClosed

func (wc *WSConn) IsClosed() bool

IsClosed return the status of conn

func (*WSConn) ReadMsg

func (wc *WSConn) ReadMsg()

ReadMsg read | write end -> write | read end -> conn end

func (*WSConn) SetData

func (wc *WSConn) SetData(data interface{})

SetData for conn

func (*WSConn) SetNode

func (wc *WSConn) SetNode(node iduck.INode)

SetNode for conn

func (*WSConn) WriteMsg

func (wc *WSConn) WriteMsg(message interface{})

WriteMsg warp msg base on conn's processor

Jump to

Keyboard shortcuts

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