Documentation
¶
Overview ¶
Package server provides a common server implementation that can connect with remote.Remote.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClientHandler ¶
type ClientHandler interface {
// NewClient is called when a new client connects to the server. It returns
// a handler that will be bound to the client.
NewClient() (MessageHandler, error)
}
ClientHandler is used to interface with client that connect to the server.
type CommonServer ¶
type CommonServer struct {
// Endpoint is the path to the socket that the server listens to.
Endpoint string
// contains filtered or unexported fields
}
CommonServer provides common functionality to connect and process messages from different clients. Implementors decide how clients and messages are handled, e.g. counting messages for testing.
func (*CommonServer) Close ¶
func (s *CommonServer) Close()
Close stops listening and closes all connections.
func (*CommonServer) Init ¶
func (s *CommonServer) Init(path string, handler ClientHandler)
Init initializes the server. It must be called before it is used.
func (*CommonServer) Start ¶
func (s *CommonServer) Start() error
Start creates the socket file and listens for new connections.
func (*CommonServer) WaitForNoClients ¶
func (s *CommonServer) WaitForNoClients()
WaitForNoClients waits until the number of clients connected reaches 0.
type MessageHandler ¶
type MessageHandler interface {
// Message processes a single message. raw contains the entire unparsed
// message. hdr is the parser message header and payload is the unparsed
// message data.
Message(raw []byte, hdr wire.Header, payload []byte) error
// Version returns what wire version of the protocol is supported.
Version() uint32
// Close closes the handler.
Close()
}
MessageHandler is used to process messages from a client.