websocket

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PingPeriodContextKey = PingPeriodContext("pingPeriod")
)

Variables

This section is empty.

Functions

func IsWebSocketUpgrade

func IsWebSocketUpgrade(req *http.Request) bool

IsWebSocketUpgrade checks to see if the request is a WebSocket connection.

func NewResponseHeader

func NewResponseHeader(req *http.Request) http.Header

NewResponseHeader returns headers needed to return to origin for completing handshake

Types

type Conn

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

func NewConn

func NewConn(ctx context.Context, rw io.ReadWriter, log *zerolog.Logger) *Conn

func (*Conn) Close

func (c *Conn) Close()

Close waits for the current write to finish. Further writes will return error

func (*Conn) Read

func (c *Conn) Read(reader []byte) (int, error)

Read will read messages from the websocket connection

func (*Conn) Write

func (c *Conn) Write(p []byte) (int, error)

Write will write messages to the websocket connection. It will not write to the connection after Close is called to fix TUN-5184

type GorillaConn

type GorillaConn struct {
	*websocket.Conn
	// contains filtered or unexported fields
}

GorillaConn is a wrapper around the standard gorilla websocket but implements a ReadWriter This is still used by access carrier

func (*GorillaConn) Read

func (c *GorillaConn) Read(p []byte) (int, error)

Read will read messages from the websocket connection

func (*GorillaConn) SetDeadline

func (c *GorillaConn) SetDeadline(t time.Time) error

SetDeadline sets both read and write deadlines, as per net.Conn interface docs: "It is equivalent to calling both SetReadDeadline and SetWriteDeadline." Note there is no synchronization here, but the gorilla implementation isn't thread safe anyway

func (*GorillaConn) Write

func (c *GorillaConn) Write(p []byte) (int, error)

Write will write messages to the websocket connection

type PingPeriodContext

type PingPeriodContext string

Jump to

Keyboard shortcuts

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