broker

package
v0.0.0-...-f67effe Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2019 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Broker

type Broker struct {
	BLock sync.Mutex
	Hubs  map[string]*Hub
	// contains filtered or unexported fields
}

func NewBroker

func NewBroker() *Broker

func (*Broker) GetActiveAgents

func (b *Broker) GetActiveAgents(user string) map[string]wire.UID

func (*Broker) GetEventManager

func (b *Broker) GetEventManager() *noti.EventManager

func (*Broker) GetHub

func (b *Broker) GetHub(user string) *Hub

func (*Broker) RemoveAgent

func (b *Broker) RemoveAgent(agentid, user string)

func (*Broker) ServeAgentWebsocket

func (b *Broker) ServeAgentWebsocket(w http.ResponseWriter, r *http.Request)

ServeAgentWebsocket serves agents

func (*Broker) ServeUserWebsocket

func (b *Broker) ServeUserWebsocket(w http.ResponseWriter, r *http.Request)

ServeUserWebsocket serves users websocket conn

type DirectPacket

type DirectPacket struct {
	Name  string
	Body  []byte
	Ntype NodeType
}

type Hub

type Hub struct {
	AllUserConns  map[wire.UID]*NodeConn // TODO lock if ..
	AllAgentConns map[wire.UID]*NodeConn

	ListOfAgents map[string]wire.UID // agentkey (not deploy key) with one most current connection

	AddConnection    chan *NodeConn
	RemoveConnection chan *NodeConn

	PacketChan chan *packet

	CDirectSend chan *DirectPacket

	Ctx       context.Context
	CtxCancel context.CancelFunc

	IDGenerator *generator

	BroadCastEvent chan []byte
	// contains filtered or unexported fields
}

func NewHub

func NewHub(ctx context.Context, e *noti.EventManager, user string) *Hub

func (*Hub) Run

func (h *Hub) Run()

type NodeConn

type NodeConn struct {
	Connectionid wire.UID
	Identifier   string   // key for agent userid for user
	Type         NodeType // UserType or AgentType

	CloseReader context.CancelFunc

	CloseWriter context.CancelFunc
	MyHub       *Hub
	Running     bool
	// contains filtered or unexported fields
}

NodeConn is used to represent both userconnection and agent connection

func NewNodeConn

func NewNodeConn(identifier string, t NodeType, conn *websocket.Conn, h *Hub) *NodeConn

func (*NodeConn) Reader

func (n *NodeConn) Reader()

func (*NodeConn) Writer

func (n *NodeConn) Writer()

type NodeType

type NodeType byte
const (
	UserType NodeType = iota
	AgentType
)

Jump to

Keyboard shortcuts

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