Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultCtx, ZeroTimeCtx CTX.Context
View Source
var DefaultCtxCancel CTX.CancelFunc
Functions ¶
func SpawnUpgradedWSs ¶
func SpawnUpgradedWSs(w http.ResponseWriter, req *http.Request)
Types ¶
type UpgradedWebsocketHandler ¶
type UpgradedWebsocketHandler func(*WSUConn)
var GlobalUpgradedWebsocketHandler UpgradedWebsocketHandler
type WSUConn ¶
type WSUConn struct { *WS.Conn NC net.Conn LocalAddr, RemoteAddr net.Addr Protocol, Address string }
WSUConn is a WebSocket Utils connection, containing both an embedded [websocket.Conn] and an embedded net.Conn. This makes the API kind of messy - the same verbs appear in different APIs, with different function signatures. Also, we rename one of them so that we don't trigger any weird compiler errors. .
func NewWSUConnForDial ¶
NewWSUConnForDial sets up fields but does not Dial. Since only a call to [websocket.Dial] (or [websocket.Accept]) actually creates an actual websocket, this func does not yet either create or initialise the embedded websocket (the [*WS.Conn]). .
func (*WSUConn) Dial ¶
Dial calls the underlying [websocket.Dial] to get an actual websocket. From the API docs:
- Dial(ctx, u string, opts *DialOpts) (*Conn, *http.Response, error)
- Dial performs a WebSocket handshake on url.
- The *http.Response is the WebSocket handshake response from the server, but you never need to close the rsp.Body yourself.
- If an error occurs, the returned response may be non nil, but you can only read the first 1024 bytes of the body.
- http:// & https:// URLs work and are interpreted as ws/wss.
- NOTE: *http.Response from Dial is &http.Response{} with a 101 status code on success
- NOTE: It specifies a text connection, not a binary connection.
.
func (*WSUConn) WriteAndReturn ¶
Click to show internal directories.
Click to hide internal directories.