websocket

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2023 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BindOp  = "bind"
	StdinOp = "stdin"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Connection Connection

	WebSockets   bool
	Address      string
	ReadBufSize  int
	WriteBufSize int

	Reconnected chan struct{}
}

func NewClient

func NewClient(address string, sessionId string, stop chan struct{}) (*Client, error)

func (*Client) Close

func (c *Client) Close() error

func (*Client) Info

func (c *Client) Info() (*Info, error)

func (*Client) ReadMessage

func (c *Client) ReadMessage(p interface{}) error

func (*Client) WriteMessage

func (c *Client) WriteMessage(p interface{}) error

type Connection

type Connection interface {
	ReadJSON(interface{}) error
	WriteJSON(interface{}) error
	Close() error
}

type Data

type Data struct {
	Op        string `json:"Op"`
	SessionID string `json:"SessionID,omitempty"`
	Data      string `json:"Data,omitempty"`
}

func GetBindData

func GetBindData(sessionId string) *Data

func GetOpData

func GetOpData(op string) *Data

func (*Data) GetWriteMessage

func (data *Data) GetWriteMessage() (string, error)

type Info

type Info struct {
	WebSocket    bool     `json:"websocket"`
	CookieNeeded bool     `json:"cookie_needed"`
	Origins      []string `json:"origins"`
	Entropy      int      `json:"entropy"`
}

type WebSocket

type WebSocket struct {
	sync.Mutex
	Address          string
	TransportAddress string
	ServerID         string
	SessionID        string
	Connection       *websocket.Conn
	Inbound          chan []byte
	Reconnected      chan struct{}
	Stop             chan struct{}
}

func NewWebSocket

func NewWebSocket(address string, sessionId string, stop chan struct{}) (*WebSocket, error)

func (*WebSocket) Close

func (w *WebSocket) Close() error

func (*WebSocket) Loop

func (w *WebSocket) Loop(sessionId string)

func (*WebSocket) ReadJSON

func (w *WebSocket) ReadJSON(v interface{}) error

func (*WebSocket) WriteJSON

func (w *WebSocket) WriteJSON(v interface{}) error

type XHR

type XHR struct {
	Address          string
	TransportAddress string
	ServerID         string
	SessionID        string
	Inbound          chan []byte
	Done             chan bool
	// contains filtered or unexported fields
}

func NewXHR

func NewXHR(address string) (*XHR, error)

func (*XHR) Close

func (x *XHR) Close() error

func (*XHR) GetSessionState

func (x *XHR) GetSessionState() sockjs.SessionState

func (*XHR) Init

func (x *XHR) Init() error

func (*XHR) ReadJSON

func (x *XHR) ReadJSON(v interface{}) error

func (*XHR) StartReading

func (x *XHR) StartReading()

func (*XHR) WriteJSON

func (x *XHR) WriteJSON(v interface{}) error

Jump to

Keyboard shortcuts

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