agent

package
v1.1.9 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2021 License: MIT Imports: 27 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Agent

type Agent struct {
	Session *session.Session // session
	// contains filtered or unexported fields
}

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

func (a *Agent) AnswerWithError(ctx context.Context, mid uint, err error)

AnswerWithError answers with an error

func (*Agent) Close

func (a *Agent) Close() error

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) GetStatus

func (a *Agent) GetStatus() int32

GetStatus gets the status

func (*Agent) Handle

func (a *Agent) Handle()

Handle handles the messages from and to a client

func (*Agent) IPVersion added in v0.7.6

func (a *Agent) IPVersion() string

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) Kick

func (a *Agent) Kick(ctx context.Context) error

Kick sends a kick packet to a client

func (*Agent) Push

func (a *Agent) Push(route string, v interface{}) error

Push implementation for session.NetworkEntity interface

func (*Agent) RemoteAddr

func (a *Agent) RemoteAddr() net.Addr

RemoteAddr implementation for session.NetworkEntity interface returns the remote network address.

func (*Agent) ResponseMID

func (a *Agent) ResponseMID(ctx context.Context, mid uint, v interface{}, isError ...bool) error

ResponseMID implementation for session.NetworkEntity interface Respond message to session

func (*Agent) SendHandshakeResponse

func (a *Agent) SendHandshakeResponse() error

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) SetLastAt

func (a *Agent) SetLastAt()

SetLastAt sets the last at to now

func (*Agent) SetStatus

func (a *Agent) SetStatus(state int32)

SetStatus sets the agent status

func (*Agent) String

func (a *Agent) String() string

String, implementation for Stringer interface

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) Close

func (a *Remote) Close() error

Close closes the remote

func (*Remote) Kick

func (a *Remote) Kick(ctx context.Context) error

Kick kicks the user

func (*Remote) Push

func (a *Remote) Push(route string, v interface{}) error

Push pushes the message to the user

func (*Remote) RemoteAddr

func (a *Remote) RemoteAddr() net.Addr

RemoteAddr returns the remote address of the user

func (*Remote) ResponseMID

func (a *Remote) ResponseMID(ctx context.Context, mid uint, v interface{}, isError ...bool) error

ResponseMID reponds the message with mid to the user

func (*Remote) SendRequest

func (a *Remote) SendRequest(ctx context.Context, serverID, reqRoute string, v interface{}) (*protos.Response, error)

SendRequest sends a request to a server

Jump to

Keyboard shortcuts

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