websocket

package
v0.2.20 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2023 License: Unlicense Imports: 11 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() (*server.Server, jrpctest.ClientMaker, func())

func WebsocketHandler

func WebsocketHandler(s *server.Server, 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 {
	*rdwr.Codec
	// contains filtered or unexported fields
}

func (*Codec) Close

func (c *Codec) Close() error

func (*Codec) PeerInfo

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

func (*Codec) RemoteAddr

func (c *Codec) RemoteAddr() string

type Server

type Server struct {
	Server *server.Server
}

func (*Server) ServeHTTP

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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