Documentation ¶
Index ¶
- type Handler
- type Protocol
- type Replayer
- type ReplayerOption
- type Result
- type Server
- type ServerOption
- func WithAllowThreadLocking(locking bool) ServerOption
- func WithLoops(loops int) ServerOption
- func WithSocketDeferAccept(daccept bool) ServerOption
- func WithSocketFastOpen(fopen bool) ServerOption
- func WithSocketReusePort(reuse bool) ServerOption
- func WithTimeout(to time.Duration) ServerOption
- func WithWorkerpoolShards(shards int) ServerOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Handler ¶
Handler is the tcp protocol handler.
func NewHandler ¶
NewHandler creates a new tcp protocol handler.
func (*Handler) Handle ¶
func (h *Handler) Handle(conn tcpserver.Connection)
Handle handles the tcp inbound connection. It parses the tcp payload and calls the protocol handler. If some useful Event is extracted from the packet, it will be sent to the listeners what previously was registered by calling RegisterEventSubscriber.
func (*Handler) RegisterEventSubscriber ¶
func (h *Handler) RegisterEventSubscriber(sub event.Subscriber)
type Protocol ¶
type Protocol interface { // Name returns the name of the protocol. Name() string // NewFrameSplitter returns instance of the split function for the protocol. NewFrameSplitter() common.FrameSplitter // Respond returns the Result as passed was processed. Respond(*internal.Session, []byte) (Result, error) }
Protocol is the tcp protocol contract.
type Replayer ¶
type Replayer struct {
// contains filtered or unexported fields
}
Replayer is replayer previously recorded data of TCP protocols.
func NewReplayer ¶
func NewReplayer(address string, proto Protocol, opts ...ReplayerOption) *Replayer
NewReplayer creates new instance of Replayer. Provide server address to where data will be sent and proto to send package by package with delay between. It is possible but not recommended to use proto by EOF to send whole file as one package.
func (*Replayer) Option ¶
func (p *Replayer) Option(opts ...ReplayerOption)
Option sets the options specified.
type ReplayerOption ¶
type ReplayerOption func(*Replayer)
func WithDelay ¶
func WithDelay(milsecs int) ReplayerOption
func WithTimeouts ¶
func WithTimeouts(to time.Duration) ReplayerOption
type Result ¶
Result is the result of handling bytes packet. It contains: CloseSession flag that signals that the session should be closed. In case like login message was failed. Response is the response bytes that shall be sent to the client. GenericAdapter that is used to get extracted and unified data from the packet.
type Server ¶
type Server struct { Handler *Handler // contains filtered or unexported fields }
Server is a TCP server for handling incoming device or retranslator connections.
func (*Server) ListenAndServe ¶
ListenAndServe starts the TCP server.
func (*Server) Option ¶
func (s *Server) Option(opts ...ServerOption)
Option sets the options specified.
func (*Server) RegisterHandler ¶
func (s *Server) RegisterHandler(f tcpserver.RequestHandlerFunc)
RegisterHandler registers a handler for incoming device or retranslator connections.
func (*Server) SetProtocol ¶
SetProtocol sets the protocol for incoming device or retranslator connections.
type ServerOption ¶
type ServerOption func(*Server)
func WithAllowThreadLocking ¶
func WithAllowThreadLocking(locking bool) ServerOption
func WithLoops ¶
func WithLoops(loops int) ServerOption
func WithSocketDeferAccept ¶
func WithSocketDeferAccept(daccept bool) ServerOption
func WithSocketFastOpen ¶
func WithSocketFastOpen(fopen bool) ServerOption
func WithSocketReusePort ¶
func WithSocketReusePort(reuse bool) ServerOption
func WithTimeout ¶
func WithTimeout(to time.Duration) ServerOption
WithTimeout sets the timeout for the server. Default is 10 minutes.
func WithWorkerpoolShards ¶
func WithWorkerpoolShards(shards int) ServerOption