Documentation ¶
Index ¶
- type Client
- type Server
- func (s *Server) AddDecoder(f Transformer) *Server
- func (s *Server) AddEncoder(f Transformer) *Server
- func (s *Server) Logger() *log.Logger
- func (s *Server) NumClient() int
- func (s *Server) Ready() bool
- func (s *Server) SetSignature(signature int32)
- func (s *Server) Start() *Server
- func (s *Server) WaitUntilReady()
- type Transformer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client represents a registration between a network connection and a pair of channels. See the documentation for Server for more details.
func (*Client) AddDecoder ¶
func (c *Client) AddDecoder(f Transformer) *Client
AddDecoder adds a new decoder to the client. Any inbound messages will be passed through all registered decoders before being sent to the channel. See the tests for an example of decoding the data using AES encryption.
func (*Client) AddEncoder ¶
func (c *Client) AddEncoder(f Transformer) *Client
AddEncoder adds a new encoder to the client. Any outbound messages will be passed through all registered encoders before being sent over the wire. See the tests for an example of encoding the data using AES encryption.
func (*Client) Done ¶
func (c *Client) Done() <-chan struct{}
Done returns a channel that will be closed once all in-flight data has been handled.
func (*Client) Logger ¶
Logger exposes the client's internal logger so that it can be configured. For example, if you want the logs to go somewhere besides standard output (the default), you can use c.Logger().SetOutput(...).
func (*Client) SetSignature ¶
SetSignature sets the signature used by the client. The signature is the first value written to the connection on each message sent. When either side receives a new message, the first four bytes must match this signature or else the read is aborted.
A sensibly-random value is provided by default, but this method can be used to enforce a custom signature instead.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server represents a registration between a network listener and a pair of channels, one for input and one for output.
func NewServer ¶
NewServer registers a pair of channels with an active listener. Gob-encoded messages received on the listener will be passed to in; any values passed to out will be gob-encoded and written to one open connection. The server uses a simple round-robin strategy when deciding which connection to send the message to; no client is favored over any others.
Note that the returned value's Start() method must be called before any messages will be passed. This gives the user an opportunity to register encoders and decoders before any data passes over the network.
func (*Server) AddDecoder ¶
func (s *Server) AddDecoder(f Transformer) *Server
AddDecoder adds a new decoder to the server. Any inbound messages will be passed through all registered decoders before being sent to the channel. See the tests for an example of decoding the data using AES encryption.
func (*Server) AddEncoder ¶
func (s *Server) AddEncoder(f Transformer) *Server
AddEncoder adds a new encoder to the server. Any outbound messages will be passed through all registered encoders before being sent over the wire. See the tests for an example of encoding the data using AES encryption.
func (*Server) Logger ¶
Logger exposes the server's internal logger so that it can be configured. For example, if you want the logs to go somewhere besides standard output (the default), you can use s.Logger().SetOutput(...).
func (*Server) SetSignature ¶
SetSignature sets the signature used by the server. The signature is the first value written to the connection on each message sent. When either side receives a new message, the first four bytes must match this signature or else the read is aborted.
A sensibly-random value is provided by default, but this method can be used to enforce a custom signature instead.
func (*Server) WaitUntilReady ¶
func (s *Server) WaitUntilReady()
WaitUntilReady blocks until the server has at least one client available.