connectionhub

package
v0.0.0-...-cb8e146 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ConnectionHub = connectionHub{
	Rooms: ConnectionNamespaces{
		Roles:        make(map[string]map[*Connection]*Client),
		Organization: make(map[string]map[*Connection]*Client),
	},
	Emit:       make(chan Message),
	Broadcast:  make(chan Message),
	Register:   make(chan Client),
	Unregister: make(chan Client),
	Clients:    make(clients),
}

Functions

This section is empty.

Types

type Client

type Client struct {
	User         string
	Organization string
	Roles        []string
	Conn         *Connection
}

func (Client) ReadPump

func (c Client) ReadPump()

func (Client) WritePump

func (c Client) WritePump()

pump incoming messages to connection hub

type Connection

type Connection struct {
	Ws   *websocket.Conn
	Send chan []byte
}

type ConnectionNamespaces

type ConnectionNamespaces struct {
	// index rooms clients by connections to allow better access
	Roles        map[string]map[*Connection]*Client
	Organization map[string]map[*Connection]*Client
}

type ConnectionRoom

type ConnectionRoom struct {
	RoomId  string
	Members string
}

type MesageTarget

type MesageTarget string
const (
	User         MesageTarget = "user"
	Organization MesageTarget = "organization"
	Role         MesageTarget = "role"
)

func (MesageTarget) String

func (t MesageTarget) String() string

type Message

type Message struct {
	Broadcast    bool
	Data         []byte
	Destinations MessageDestinations
	Origin       string
}

type MessageDestinations

type MessageDestinations struct {
	Users         []string
	Roles         []string
	Organizations []string
}

type WsMessage

type WsMessage struct {
	Broadcast     bool                   `json:"broadcast"`
	Users         []string               `json:"users"`
	Roles         []string               `json:"roles"`
	Organizations []string               `json:"organizations"`
	Payload       map[string]interface{} `json:"payload"`
}

Jump to

Keyboard shortcuts

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