Documentation
¶
Index ¶
- Constants
- type Connection
- func (this *Connection) GetConnection() *net.TCPConn
- func (this *Connection) GetProperty(key string) (interface{}, error)
- func (this *Connection) GetProtoc() iface.IServerProtocol
- func (this *Connection) GetSessionId() uint32
- func (this *Connection) LostConnection()
- func (this *Connection) RemoteAddr() net.Addr
- func (this *Connection) RemoveProperty(key string)
- func (this *Connection) Send(data []byte) error
- func (this *Connection) SendBuff(data []byte) error
- func (this *Connection) SetProperty(key string, value interface{})
- func (this *Connection) Start()
- func (this *Connection) StartWriteThread()
- func (this *Connection) Stop()
- type ConnectionMgr
- type MsgHandle
- type PBDataPack
- type PkgAll
- type PkgData
- type Protocol
- func (this *Protocol) AddRpcRouter(router interface{})
- func (this *Protocol) DoFrequencyControl(fconn iface.Iconnection) error
- func (this *Protocol) GetDataPack() iface.Idatapack
- func (this *Protocol) GetMsgHandle() iface.Imsghandle
- func (this *Protocol) InitWorker(poolsize int32)
- func (this *Protocol) OnConnectionLost(fconn iface.Iconnection)
- func (this *Protocol) OnConnectionMade(fconn iface.Iconnection)
- func (this *Protocol) SetFrequencyControl(fconn iface.Iconnection)
- func (this *Protocol) StartReadThread(fconn iface.Iconnection)
- type TcpClient
- func (this *TcpClient) GetConnection() *net.TCPConn
- func (this *TcpClient) GetProperty(key string) (interface{}, error)
- func (this *TcpClient) ReConnection() bool
- func (this *TcpClient) RemoveProperty(key string)
- func (this *TcpClient) Send(data []byte) error
- func (this *TcpClient) SetProperty(key string, value interface{})
- func (this *TcpClient) Start()
- func (this *TcpClient) Stop(isforce bool)
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 ¶
func NewMsgHandle ¶
func NewMsgHandle() *MsgHandle
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 ¶
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 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 (*Protocol) GetMsgHandle ¶
func (this *Protocol) GetMsgHandle() iface.Imsghandle
func (*Protocol) InitWorker ¶
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 NewTcpClient ¶
func NewTcpClient(ip string, port int, protoc iface.IClientProtocol) *TcpClient
func (*TcpClient) GetConnection ¶
func (*TcpClient) GetProperty ¶
func (*TcpClient) ReConnection ¶
func (*TcpClient) RemoveProperty ¶
func (*TcpClient) SetProperty ¶
Click to show internal directories.
Click to hide internal directories.