Documentation ¶
Index ¶
- Constants
- Variables
- func Encode(msg *Message) ([]byte, error)
- func MsgEncode(m *Message) ([]byte, error)
- type Agent
- func (a *Agent) Close() error
- func (a *Agent) GetConn() net.Conn
- func (a *Agent) GetConnID() int
- func (a *Agent) RemoteAddr() net.Addr
- func (a *Agent) SendBuffMsg(msgID int32, data []byte) error
- func (a *Agent) SendMsg(msgID int32, data []byte) error
- func (a *Agent) StartWriter()
- func (a *Agent) String() string
- type Decoder
- type Message
- type MsgHandle
- func (h *MsgHandle) AddRouter(msgId int32, router Router)
- func (h *MsgHandle) DoMsgHandler(request *Request)
- func (h *MsgHandle) Handle(iConn tcpface.IConnection)
- func (h *MsgHandle) SendMsgToTaskQueue(request *Request)
- func (h *MsgHandle) StartOneWorker(workerID int, taskQueue chan *Request)
- func (h *MsgHandle) StartWorkerPool()
- type Packet
- type Request
- type Router
Constants ¶
View Source
const ( HeadLength = 4 MaxPacketSize = 64 * 1024 )
Codec constants.
Variables ¶
View Source
var ErrPacketSizeExceed = errors.New("codec: packet size exceed")
ErrPacketSizeExceed is the error used for encode/decode.
Functions ¶
Types ¶
type Agent ¶
func (*Agent) RemoteAddr ¶
RemoteAddr implementation for session.NetworkEntity interface
func (*Agent) SendBuffMsg ¶
SendBuffMsg 发生BuffMsg
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
A Decoder reads and decodes network data slice
func NewDecoder ¶
func NewDecoder() *Decoder
NewDecoder returns a new decoder that used for decode network bytes slice.
type Message ¶
Message represents a unmarshaled message or a message which to be marshaled
func MsgDecode ¶
MsgDecode unmarshal the bytes slice to a message See ref: https://github.com/lonnng/nano/blob/master/docs/communication_protocol.md
type MsgHandle ¶
type MsgHandle struct { Apis map[int32]Router //存放每个MsgId 所对应的处理方法的map属性 WorkerPoolSize int //业务工作Worker池的数量 TaskQueue []chan *Request //Worker负责取任务的消息队列 }
func NewMsgHandle ¶
func NewMsgHandle() *MsgHandle
func (*MsgHandle) DoMsgHandler ¶
DoMsgHandler 马上以非阻塞方式处理消息
func (*MsgHandle) Handle ¶
func (h *MsgHandle) Handle(iConn tcpface.IConnection)
func (*MsgHandle) SendMsgToTaskQueue ¶
SendMsgToTaskQueue 将消息交给TaskQueue,由worker进行处理
func (*MsgHandle) StartOneWorker ¶
StartOneWorker 启动一个Worker工作流程
func (*MsgHandle) StartWorkerPool ¶
func (h *MsgHandle) StartWorkerPool()
StartWorkerPool 启动worker工作池
type Request ¶
type Request struct {
// contains filtered or unexported fields
}
func (*Request) GetConnection ¶
func (r *Request) GetConnection() tcpface.IConnection
func (*Request) GetMsgData ¶
func (*Request) GetServerID ¶
Click to show internal directories.
Click to hide internal directories.