tcpGateway

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2021 License: BSD-3-Clause Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnsupportedProtocol  = errors.New("gateway protocol is not supported")
	ErrWriteToClosedConn    = errors.New("write to closed conn")
	ErrUnexpectedSocketRead = errors.New("unexpected socket read")
	ErrOpCloseReceived      = errors.New("close operation received")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	Concurrency   int
	ListenAddress string
	MaxBodySize   int
	MaxIdleTime   time.Duration
	Protocol      gateway.Protocol
	ExternalAddrs []string
	HttpProxy     *HttpProxy
}

Config

type Gateway

type Gateway struct {
	gateway.ConnectHandler
	gateway.MessageHandler
	gateway.CloseHandler
	// contains filtered or unexported fields
}

Gateway

func MustNew

func MustNew(config Config) *Gateway

func New

func New(config Config) (*Gateway, error)

New

func (*Gateway) Addr

func (g *Gateway) Addr() []string

Addr return the address which gateway is listen on

func (*Gateway) GetConn

func (g *Gateway) GetConn(connID uint64) rony.Conn

GetConn returns the connection identified by connID

func (*Gateway) Run

func (g *Gateway) Run()

Run is blocking and runs the server endless loop until a non-temporary error happens

func (*Gateway) Shutdown

func (g *Gateway) Shutdown()

Shutdown

func (*Gateway) Start

func (g *Gateway) Start()

Start is non-blocking and call the Run function in background

func (*Gateway) TotalConnections

func (g *Gateway) TotalConnections() int

type HttpProxy added in v0.6.0

type HttpProxy struct {
	// contains filtered or unexported fields
}

func (*HttpProxy) Set added in v0.6.0

func (hp *HttpProxy) Set(method, path string, p gateway.Proxy)

type SimpleProxy added in v0.6.0

type SimpleProxy struct {
	OnRequestFunc  func(conn rony.Conn, date []byte) []byte
	OnResponseFunc func(data []byte) []byte
}

func (*SimpleProxy) OnRequest added in v0.6.0

func (s *SimpleProxy) OnRequest(conn rony.Conn, data []byte) []byte

func (*SimpleProxy) OnResponse added in v0.6.0

func (s *SimpleProxy) OnResponse(data []byte) []byte

type UnsafeConn

type UnsafeConn interface {
	net.Conn
	UnsafeConn() net.Conn
}

Directories

Path Synopsis
Package wsutil provides utilities for working with WebSocket protocol.
Package wsutil provides utilities for working with WebSocket protocol.

Jump to

Keyboard shortcuts

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