ws

package
v1.17.4 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2019 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BUFSIZE = 10
)

Variables

View Source
var (
	ErrNotConnected = errors.New("not connected")
	ErrNotRunning   = errors.New("not running")
	ErrStopped      = errors.New("stopped")
	ErrSendTimeout  = errors.New("send timeout")
	ErrRecvTimeout  = errors.New("recv timeout")
)

Functions

This section is empty.

Types

type ConcurrentMultiplexer

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

func NewConcurrentMultiplexer

func NewConcurrentMultiplexer(name string, conn Connector, commProc Processor, concurrency uint) *ConcurrentMultiplexer

func (*ConcurrentMultiplexer) Done

func (m *ConcurrentMultiplexer) Done() chan bool

func (*ConcurrentMultiplexer) Send

func (m *ConcurrentMultiplexer) Send(data interface{}) (interface{}, error)

func (*ConcurrentMultiplexer) Start

func (m *ConcurrentMultiplexer) Start() error

func (*ConcurrentMultiplexer) Stop

func (m *ConcurrentMultiplexer) Stop()

type Connection

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

func ExistingConnection

func ExistingConnection(url, origin string, conn *websocket.Conn) *Connection

func NewConnection

func NewConnection(url, origin string, headers map[string]string) *Connection

func (*Connection) Conn

func (c *Connection) Conn(conn *websocket.Conn) *websocket.Conn

func (*Connection) Connect

func (c *Connection) Connect()

func (*Connection) ConnectChan

func (c *Connection) ConnectChan() chan bool

func (*Connection) ConnectOnce

func (c *Connection) ConnectOnce(timeout uint) error

func (*Connection) Disconnect

func (c *Connection) Disconnect() error

func (*Connection) Recv

func (c *Connection) Recv(data interface{}, timeout uint) error

func (*Connection) RecvBytes

func (c *Connection) RecvBytes(timeout uint) ([]byte, error)

func (*Connection) RecvChan

func (c *Connection) RecvChan() chan []byte

func (*Connection) RecvErrorChan

func (c *Connection) RecvErrorChan() chan Error

func (*Connection) Send

func (c *Connection) Send(data interface{}, timeout uint) error

func (*Connection) SendBytes

func (c *Connection) SendBytes(bytes []byte, timeout uint) error

func (*Connection) SendChan

func (c *Connection) SendChan() chan []byte

func (*Connection) SendErrorChan

func (c *Connection) SendErrorChan() chan Error

func (*Connection) Start

func (c *Connection) Start()

func (*Connection) Stop

func (c *Connection) Stop()

type Connector

type Connector interface {
	Start()
	Stop()
	Connect()
	ConnectOnce(timeout uint) error
	ConnectChan() chan bool
	Disconnect() error
	Send(data interface{}, timeout uint) error
	Recv(data interface{}, timeout uint) error
	SendBytes(bytes []byte, timeout uint) error
	RecvBytes(timeout uint) ([]byte, error)
	SendChan() chan []byte
	RecvChan() chan []byte
	SendErrorChan() chan Error
	RecvErrorChan() chan Error
	Conn(conn *websocket.Conn) *websocket.Conn
}

type ConnectorFactory

type ConnectorFactory interface {
	Make(url, origin string) Connector
	Use(url, origin string, conn *websocket.Conn) Connector
}

type Error

type Error struct {
	Bytes []byte
	Error error
}

type Multiplexer

type Multiplexer interface {
	Start() error
	Stop()
	Done() chan bool
	Send(msg interface{}) (interface{}, error)
}

type Processor

type Processor interface {
	BeforeSend(interface{}) (id string, bytes []byte, err error)
	AfterRecv([]byte) (id string, data interface{}, err error)
	Timeout(id string)
}

A Processor lets the API see and react to messages as they're sent and received. For agent communicators, we update oN tables for certain commands. For example, when a tool is stopped, we set oN.agent_config.running=false. For API communicators, we handle requests from the remote API. For example, a remote API routes an agent status request to us because we have the agent. A comm processor is also responsible for uniquely identifying messages and serializing them to []byte for sending and receiving.

type ProcessorFactory

type ProcessorFactory interface {
	Make() Processor
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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