ws

package
v1.22.0-beta.0 Latest Latest
Warning

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

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

README

ws 模块 copy from newton-agent

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Upgrader = websocket.Upgrader{

	CheckOrigin: func(r *http.Request) bool {
		return true
	},
}

Functions

This section is empty.

Types

type StreamHandler

type StreamHandler struct {
	WsConn      *WsConnection
	ResizeEvent chan remotecommand.TerminalSize
}

func (*StreamHandler) Next

func (handler *StreamHandler) Next() (size *remotecommand.TerminalSize)

func (*StreamHandler) Read

func (handler *StreamHandler) Read(p []byte) (size int, err error)

func (*StreamHandler) Write

func (handler *StreamHandler) Write(p []byte) (size int, err error)

type WsConnection

type WsConnection struct {
	OnClose func()
	// contains filtered or unexported fields
}

func InitWebsocket

func InitWebsocket(resp http.ResponseWriter, req *http.Request) (wsConn *WsConnection, err error)

func (*WsConnection) WsClose

func (wsConn *WsConnection) WsClose()

func (*WsConnection) WsRead

func (wsConn *WsConnection) WsRead() (msg *WsMessage, err error)

func (*WsConnection) WsWrite

func (wsConn *WsConnection) WsWrite(messageType int, data []byte) (err error)

type WsMessage

type WsMessage struct {
	MessageType int
	Data        []byte
}

websocket消息

Jump to

Keyboard shortcuts

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