fnet

package
v0.0.0-...-52d6a69 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2019 License: Apache-2.0, Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	XINGO_CONN_PROPERTY_CTIME = "xingo_ctime"
	XINGO_CONN_PROPERTY_NAME  = "xingo_tcpserver_name"
)
View Source
const (
	MAX_RETRY      = 1024 //父节点掉线最大重连次数
	RETRY_INTERVAL = 60   //重连间隔60s
)
View Source
const (
	MaxPacketSize = 1024 * 1024
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Connection

type Connection struct {
	Conn *net.TCPConn

	SessionId   uint32
	Protoc      iface.IServerProtocol
	PropertyBag map[string]interface{}

	SendBuffChan chan []byte
	ExtSendChan  chan bool
	// contains filtered or unexported fields
}

func NewConnection

func NewConnection(conn *net.TCPConn, sessionId uint32, protoc iface.IServerProtocol) *Connection

func (*Connection) GetConnection

func (this *Connection) GetConnection() *net.TCPConn

func (*Connection) GetProperty

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

func (*Connection) GetProtoc

func (this *Connection) GetProtoc() iface.IServerProtocol

func (*Connection) GetSessionId

func (this *Connection) GetSessionId() uint32

func (*Connection) LostConnection

func (this *Connection) LostConnection()

func (*Connection) RemoteAddr

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

func (*Connection) RemoveProperty

func (this *Connection) RemoveProperty(key string)

func (*Connection) Send

func (this *Connection) Send(data []byte) error

func (*Connection) SendBuff

func (this *Connection) SendBuff(data []byte) error

func (*Connection) SetProperty

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

func (*Connection) Start

func (this *Connection) Start()

func (*Connection) StartWriteThread

func (this *Connection) StartWriteThread()

func (*Connection) Stop

func (this *Connection) Stop()

type ConnectionMgr

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

func NewConnectionMgr

func NewConnectionMgr() *ConnectionMgr

func (*ConnectionMgr) Add

func (this *ConnectionMgr) Add(conn iface.Iconnection)

func (*ConnectionMgr) Get

func (this *ConnectionMgr) Get(sid uint32) (iface.Iconnection, error)

func (*ConnectionMgr) Len

func (this *ConnectionMgr) Len() int

func (*ConnectionMgr) Remove

func (this *ConnectionMgr) Remove(conn iface.Iconnection) error

type MsgHandle

type MsgHandle struct {
	PoolSize  int32
	TaskQueue []chan *PkgAll
	Apis      map[uint32]reflect.Value
}

func NewMsgHandle

func NewMsgHandle() *MsgHandle

func (*MsgHandle) AddRouter

func (this *MsgHandle) AddRouter(router interface{})

func (*MsgHandle) DeliverToMsgQueue

func (this *MsgHandle) DeliverToMsgQueue(pkg interface{})

一致性路由,保证同一连接的数据转发给相同的goroutine

func (*MsgHandle) DoMsgFromGoRoutine

func (this *MsgHandle) DoMsgFromGoRoutine(pkg interface{})

func (*MsgHandle) HandleError

func (this *MsgHandle) HandleError(err interface{})

func (*MsgHandle) StartWorkerLoop

func (this *MsgHandle) StartWorkerLoop(poolSize int)

type PBDataPack

type PBDataPack struct{}

func NewPBDataPack

func NewPBDataPack() *PBDataPack

func (*PBDataPack) GetHeadLen

func (this *PBDataPack) GetHeadLen() int32

func (*PBDataPack) Pack

func (this *PBDataPack) Pack(msgId uint32, data interface{}) (out []byte, err error)

func (*PBDataPack) Unpack

func (this *PBDataPack) Unpack(headdata []byte) (interface{}, error)

type PkgAll

type PkgAll struct {
	Pdata *PkgData
	Fconn iface.Iconnection
}

type PkgData

type PkgData struct {
	Len   uint32
	MsgId uint32
	Data  []byte
}

type Protocol

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

func NewProtocol

func NewProtocol() *Protocol

func (*Protocol) AddRpcRouter

func (this *Protocol) AddRpcRouter(router interface{})

func (*Protocol) DoFrequencyControl

func (this *Protocol) DoFrequencyControl(fconn iface.Iconnection) error

func (*Protocol) GetDataPack

func (this *Protocol) GetDataPack() iface.Idatapack

func (*Protocol) GetMsgHandle

func (this *Protocol) GetMsgHandle() iface.Imsghandle

func (*Protocol) InitWorker

func (this *Protocol) InitWorker(poolsize int32)

func (*Protocol) OnConnectionLost

func (this *Protocol) OnConnectionLost(fconn iface.Iconnection)

func (*Protocol) OnConnectionMade

func (this *Protocol) OnConnectionMade(fconn iface.Iconnection)

func (*Protocol) SetFrequencyControl

func (this *Protocol) SetFrequencyControl(fconn iface.Iconnection)

func (*Protocol) StartReadThread

func (this *Protocol) StartReadThread(fconn iface.Iconnection)

type TcpClient

type TcpClient struct {
	PropertyBag map[string]interface{}
	// contains filtered or unexported fields
}

func NewReConnTcpClient

func NewReConnTcpClient(ip string, port int, protoc iface.IClientProtocol, maxRetry int,
	retryInterval int, reconnCB func(iface.Iclient)) *TcpClient

func NewTcpClient

func NewTcpClient(ip string, port int, protoc iface.IClientProtocol) *TcpClient

func (*TcpClient) GetConnection

func (this *TcpClient) GetConnection() *net.TCPConn

func (*TcpClient) GetProperty

func (this *TcpClient) GetProperty(key string) (interface{}, error)

func (*TcpClient) ReConnection

func (this *TcpClient) ReConnection() bool

func (*TcpClient) RemoveProperty

func (this *TcpClient) RemoveProperty(key string)

func (*TcpClient) Send

func (this *TcpClient) Send(data []byte) error

func (*TcpClient) SetProperty

func (this *TcpClient) SetProperty(key string, value interface{})

func (*TcpClient) Start

func (this *TcpClient) Start()

func (*TcpClient) Stop

func (this *TcpClient) Stop(isforce bool)

Jump to

Keyboard shortcuts

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