websocket

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2024 License: Unlicense Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxRequestContentLength = 1024 * 1024 * 5
	ContentType             = "application/json"
	WsReadBuffer            = 1024
	WsWriteBuffer           = 1024
	WsPingInterval          = 60 * time.Second
	WsPingWriteTimeout      = 5 * time.Second
	WsPongTimeout           = 30 * time.Second
	WsMessageSizeLimit      = 128 * 1024 * 1024
)

Variables

This section is empty.

Functions

func ServerMaker

func ServerMaker() (jsonrpc.Handler, jrpctest.ClientMaker, func())

func WebsocketHandler

func WebsocketHandler(s jsonrpc.Handler, allowedOrigins []string) http.Handler

WebsocketHandler returns a handler that serves JSON-RPC to WebSocket connections.

allowedOrigins should be a comma-separated list of allowed origin URLs. To allow connections with any origin, pass "*".

func WsClientHeaders

func WsClientHeaders(endpoint, origin string) (string, http.Header, error)

Types

type Client

type Client struct {
	*rdwr.Client
	// contains filtered or unexported fields
}

func DialWebsocket

func DialWebsocket(ctx context.Context, endpoint, origin string) (*Client, error)

DialWebsocket creates a new RPC client that communicates with a JSON-RPC server that is listening on the given endpoint.

The context is used for the initial connection establishment. It does not affect subsequent interactions with the client.

func DialWebsocketWithDialer

func DialWebsocketWithDialer(ctx context.Context, endpoint, origin string, opts *websocket.DialOptions) (*Client, error)

that is listening on the given endpoint using the provided dialer.

func (*Client) Close

func (c *Client) Close() error

type Codec

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

func (*Codec) Close

func (c *Codec) Close() error

func (*Codec) Closed added in v0.3.8

func (c *Codec) Closed() <-chan struct{}

func (*Codec) Flush added in v0.3.9

func (c *Codec) Flush() error

func (*Codec) PeerInfo

func (c *Codec) PeerInfo() jsonrpc.PeerInfo

func (*Codec) ReadBatch added in v0.3.8

func (c *Codec) ReadBatch(ctx context.Context) (jsonrpc.Bundle, error)

func (*Codec) RemoteAddr

func (c *Codec) RemoteAddr() string

func (*Codec) Write added in v0.3.9

func (c *Codec) Write(p []byte) (n int, err error)

type Server

type Server struct {
	Handler jsonrpc.Handler
}

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

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