sockjs

package
v5.3.1 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetBytesReader

func GetBytesReader(data []byte) *bytes.Reader

GetBytesReader from pool.

func GetStringReader

func GetStringReader(data string) *strings.Reader

GetStringReader from pool.

func NewCancelContext

func NewCancelContext(ctx context.Context, ch <-chan struct{}) context.Context

NewCancelContext returns a wrapper context around original context that will be canceled on channel close.

func PutBytesReader

func PutBytesReader(reader *bytes.Reader)

PutBytesReader to pool.

func PutStringReader

func PutStringReader(reader *strings.Reader)

PutStringReader to pool.

Types

type Config

type Config struct {
	// HandlerPrefix sets prefix for SockJS handler endpoint path.
	HandlerPrefix string

	// URL is an address to SockJS client javascript library. Required for iframe-based
	// transports to work. This URL should lead to the same SockJS client version as used
	// for connecting on the client side.
	URL string

	// CheckOrigin allows deciding whether to use CORS or not in XHR case.
	// When false returned then CORS headers won't be set.
	CheckOrigin func(*http.Request) bool

	// WebsocketCheckOrigin allows setting custom CheckOrigin func for underlying
	// Gorilla Websocket based websocket.Upgrader.
	WebsocketCheckOrigin func(*http.Request) bool

	// WebsocketReadBufferSize is a parameter that is used for raw websocket.Upgrader.
	// If set to zero reasonable default value will be used.
	WebsocketReadBufferSize int

	// WebsocketWriteBufferSize is a parameter that is used for raw websocket.Upgrader.
	// If set to zero reasonable default value will be used.
	WebsocketWriteBufferSize int

	// WebsocketUseWriteBufferPool enables using buffer pool for writes in Websocket transport.
	WebsocketUseWriteBufferPool bool

	// WebsocketWriteTimeout is maximum time of write message operation.
	// Slow client will be disconnected.
	// By default, 1 * time.Second will be used.
	WebsocketWriteTimeout time.Duration

	centrifuge.PingPongConfig
}

Config represents config for SockJS handler.

type Handler

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

Handler accepts SockJS connections. SockJS has a bunch of fallback transports when WebSocket connection is not supported. It comes with additional costs though: small protocol framing overhead, lack of binary support, more goroutines per connection, and you need to use sticky session mechanism on your load balancer in case you are using HTTP-based SockJS fallbacks and have more than one Centrifuge Node on a backend (so SockJS to be able to emulate bidirectional protocol). So if you can afford it - use WebsocketHandler only.

func NewHandler

func NewHandler(node *centrifuge.Node, config Config) *Handler

NewHandler creates new Handler.

func (*Handler) ServeHTTP

func (s *Handler) ServeHTTP(rw http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

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