clients

package
v2.1.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2018 License: MIT Imports: 12 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	ID      string `json:"id"`
	Name    string `json:"name"`
	Type    string `json:"type"`
	MediaID int    `json:"mediaID"`
}

Client represent the mapping between a ID and a readable name given by user

type ClientJSON

type ClientJSON struct {
	*Client
	IsConnected bool `json:"isConnected"`
}

ClientJSON respresent the client that will be sent to back-office

type Config

type Config struct {
	Clients map[string]*Client `json:"clients"`
}

type Manager

type Manager struct {
	Config *Config
	// contains filtered or unexported fields
}

Manager manage clients config.

func (*Manager) Commit

func (m *Manager) Commit() error

Commit writes the current configuration to the save file

func (*Manager) Get

func (m *Manager) Get(clientID string) (*Client, bool)

Get return the client associated to an ID

func (*Manager) GetAll

func (m *Manager) GetAll() map[string]*Client

GetAll returns the complete map of registered clients (the client ID is the key)

func (*Manager) GetConfig

func (m *Manager) GetConfig() interface{}

GetConfig return a non-typed pointer to the configuration of the manager This is use by commons.LoadFromDB for Decoding configuration from JSON.

func (*Manager) GetSaveFilePath

func (m *Manager) GetSaveFilePath() (string, string, string)

GetSaveFilePath return the path of the save file for the configuration Returns (fullPath, configPath, configFileName)

func (*Manager) LoadFromDB

func (m *Manager) LoadFromDB()

LoadFromDB loads medias configuration from DB and stor it in memory

type Service

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

Service is the websocket connection handler

func NewService

func NewService() *Service

Create a new

func (*Service) CreateHandler

func (s *Service) CreateHandler(w http.ResponseWriter, r *http.Request)

CreateHandler create a new client entry in the database.

func (*Service) DeleteAllHandler

func (s *Service) DeleteAllHandler(w http.ResponseWriter, r *http.Request)

func (*Service) DeleteHandler

func (s *Service) DeleteHandler(w http.ResponseWriter, r *http.Request)

DeleteHandler delete a client from the database

func (*Service) GetAllHandler

func (s *Service) GetAllHandler(w http.ResponseWriter, r *http.Request)

GetAllHandler send the list of all registered clients.

func (*Service) GetHandler

func (s *Service) GetHandler(w http.ResponseWriter, r *http.Request)

GetHandler send the requested client configuration.

func (*Service) GetManager

func (s *Service) GetManager() *Manager

GetManager returns the client manager of the service

func (*Service) SendByID

func (s *Service) SendByID(clientID string, msg string)

func (*Service) SendByMedia

func (s *Service) SendByMedia(mediaID int, msg string)

SendByMedia sends a message to each client connected to the given media

func (*Service) UpdateHandler

func (s *Service) UpdateHandler(w http.ResponseWriter, r *http.Request)

UpdateHandler update a client configuration in the database

func (*Service) WSConnectionHandler

func (s *Service) WSConnectionHandler(w http.ResponseWriter, r *http.Request)

WSConnectionHandler Handles a connection request from a given client.

func (*Service) WaitForClose

func (s *Service) WaitForClose(clientID string) <-chan bool

type WSClient

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

WSClient represent a websocket connection to a client.

func (*WSClient) Close

func (ws *WSClient) Close()

Close gracefully close and cleanup the client

func (*WSClient) String

func (ws *WSClient) String() string

func (*WSClient) Unregister

func (ws *WSClient) Unregister()

Unregister wsclient from its service (the call the Close will be made by the service)

Jump to

Keyboard shortcuts

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