ws

package
v0.0.0-...-fe1665b Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const MAX_BUF_SIZE = 1024 * 1024 * 8

Variables

View Source
var UserAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36"

Functions

func MakeTransport

func MakeTransport(conn WSConn) io.ReadWriteCloser

MakeTransport wraps a websocket connection to a io.ReadWriteCloser by making use of only binary type frames.

Types

type WSConn

type WSConn interface {
	ReadFrame() (*WSFrame, error)
	WriteFrame(*WSFrame) (int, error)
	io.Closer
}

func Dial

func Dial(uriStr string) (WSConn, error)

Dial is to initiate a websocket connection. Dial accepts an URL argument like `wss://localhost:3243/hi`.

func WebSocketHandshake

func WebSocketHandshake(req *http.Request, w http.ResponseWriter) (WSConn, error)

WebSocketHandshake works at server-side. It hijacks the connection and continues with handshaking, after that it returns a closable frame read-writer.

type WSFrame

type WSFrame struct {
	Fin  bool
	Op   uint8
	Data []byte
}

Jump to

Keyboard shortcuts

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