server

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2021 License: GPL-3.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bandwidth

type Bandwidth interface {
	NewReader(io.Reader) io.Reader
	NewWriter(io.Writer) io.Writer
	Get() (up, down float64, totalUp, totalDown uint64)
}

type Config

type Config struct {
	// Arbitrary string clients will need to be able to connect
	ProtocolVersion string

	Key *crypto.Key

	Log *log.Logger

	// HTTP/WS listen address
	HTTPAddress string
	// TCP listen address
	TCPAddress string

	// Path to store databases
	StorePath string

	// Path to store uploads and from which the http server can serve files
	UploadsPath   string
	MaxUploadSize int64

	// HTTPS certs, leave empty to disable TLS
	Cert    []byte
	CertKey []byte

	Router    simplehttp.Router
	RWFactory channel.RWFactory

	// Interval to log bandwidth, 0 = no logging
	LogBandwidth time.Duration
}

type NoopBandwidth

type NoopBandwidth struct{}

func (*NoopBandwidth) Get

func (n *NoopBandwidth) Get() (up, down float64, tup, tdown uint64)

func (*NoopBandwidth) NewReader

func (n *NoopBandwidth) NewReader(r io.Reader) io.Reader

func (*NoopBandwidth) NewWriter

func (n *NoopBandwidth) NewWriter(w io.Writer) io.Writer

type Server

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

func New

func New(c Config) (*Server, error)

func (*Server) AddChannel

func (s *Server) AddChannel(name string, c channel.Channel) error

func (*Server) Broadcast

func (s *Server) Broadcast(f channel.ClientFilter, m channel.Msg) error

func (*Server) BroadcastBatch

func (s *Server) BroadcastBatch(b []channel.Batch) error

func (*Server) Close

func (s *Server) Close()

func (*Server) GetUsers

func (s *Server) GetUsers(ch string) []channel.User

func (*Server) Init

func (s *Server) Init() error

func (*Server) MustAddChannel

func (s *Server) MustAddChannel(name string, c channel.Channel)

func (*Server) MustSetUserUpdateHandler

func (s *Server) MustSetUserUpdateHandler(h channel.UserUpdateHandler)

func (*Server) Run

func (s *Server) Run() error

func (*Server) Save

func (s *Server) Save() error

func (*Server) SetUserUpdateHandler

func (s *Server) SetUserUpdateHandler(h channel.UserUpdateHandler) error

func (*Server) Upload

func (s *Server) Upload(filename string, r io.Reader) (*url.URL, error)

Jump to

Keyboard shortcuts

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