Documentation ¶
Index ¶
- Constants
- type Agent
- func (a *Agent) AnswerWithError(ctx context.Context, mid uint32, err error)
- func (a *Agent) Close() error
- func (a *Agent) GetStatus() int32
- func (a *Agent) Handle()
- func (a *Agent) IPVersion() string
- func (a *Agent) Kick(ctx context.Context) error
- func (a *Agent) Push(route string, v interface{}) error
- func (a *Agent) RemoteAddr() net.Addr
- func (a *Agent) ResponseMID(ctx context.Context, mid uint32, typ message.Type, v interface{}, ...) error
- func (a *Agent) SendHandshakeResponse() error
- func (a *Agent) SendHeartBeatResponse() error
- func (a *Agent) SendRequest(ctx context.Context, serverID, route string, v interface{}) (*protos.Response, error)
- func (a *Agent) SetLastAt()
- func (a *Agent) SetStatus(state int32)
- func (a *Agent) StartHeartbeatTimer()
- func (a *Agent) String() string
- type Remote
- func (a *Remote) Close() error
- func (a *Remote) Kick(ctx context.Context) error
- func (a *Remote) Push(route string, v interface{}) error
- func (a *Remote) RemoteAddr() net.Addr
- func (a *Remote) ResponseMID(ctx context.Context, mid uint32, typ message.Type, v interface{}, ...) error
- func (a *Remote) SendRequest(ctx context.Context, serverID, reqRoute string, v interface{}) (*protos.Response, error)
Constants ¶
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Agent ¶
Agent corresponds to a user and is used for storing raw Conn information
func NewAgent ¶
func NewAgent( conn net.Conn, packetDecoder codec.PacketDecoder, packetEncoder codec.PacketEncoder, serializer serialize.Serializer, heartbeatTime time.Duration, messagesBufferSize int, dieChan chan bool, messageEncoder message.Encoder, metricsReporters []metrics.Reporter, ) *Agent
NewAgent create new agent instance
func (*Agent) AnswerWithError ¶
AnswerWithError answers with an error TODO: 抛出异常, 处理关闭a.Close()
func (*Agent) Close ¶
Close closes the agent, cleans inner state and closes low-level connection. Any blocked Read or Write operations will be unblocked and return errors.
func (*Agent) IPVersion ¶
IPVersion returns the remote address ip version. net.TCPAddr and net.UDPAddr implementations of String() always construct result as <ip>:<port> on both ipv4 and ipv6. Also, to see if the ip is ipv6 they both check if there is a colon on the string. So checking if there are more than one colon here is safe.
func (*Agent) RemoteAddr ¶
RemoteAddr implementation for session.NetworkEntity interface returns the remote network address.
func (*Agent) ResponseMID ¶
func (a *Agent) ResponseMID(ctx context.Context, mid uint32, typ message.Type, v interface{}, isError ...bool) error
ResponseMID implementation for session.NetworkEntity interface Respond message to session
func (*Agent) SendHandshakeResponse ¶
SendHandshakeResponse sends a handshake response
func (*Agent) SendHeartBeatResponse ¶
SendHandshakeResponse sends a handshake response
func (*Agent) SendRequest ¶
func (a *Agent) SendRequest(ctx context.Context, serverID, route string, v interface{}) (*protos.Response, error)
SendRequest sends a request to a server
func (*Agent) StartHeartbeatTimer ¶
func (a *Agent) StartHeartbeatTimer()
type Remote ¶
type Remote struct { Session *session.Session // session // contains filtered or unexported fields }
Remote corresponding to another server
func NewRemote ¶
func NewRemote( sess *protos.Session, reply string, rpcClient cluster.RPCClient, encoder codec.PacketEncoder, serializer serialize.Serializer, serviceDiscovery cluster.ServiceDiscovery, frontendID string, messageEncoder message.Encoder, ) (*Remote, error)
NewRemote create new Remote instance
func (*Remote) RemoteAddr ¶
RemoteAddr returns the remote address of the user