client

package
v0.0.0-...-b30106d Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2020 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrClientAlreadyExists = errors.New("")
)

Functions

This section is empty.

Types

type ClientError

type ClientError struct {
	ClientID string
	Message  string
}

func (ClientError) Error

func (ce ClientError) Error() string

type Conn

type Conn interface {
	ReadMessage() (messageType int, p []byte, err error)
	WriteMessage(messageType int, data []byte) error
	WriteJSON(v interface{}) error
	Close() error
}

type Instance

type Instance struct {
	ID string

	sync.Mutex
	LastMessages *structures.Queue
	Pool         pool
	// contains filtered or unexported fields
}

Instance type which is a client

func NewConn

func NewConn(ws Conn, pool pool, ID string) *Instance

Create a new connection/client

func (*Instance) Read

func (i *Instance) Read()

func (*Instance) SendMessage

func (i *Instance) SendMessage()

type Pool

type Pool struct {
	Broadcast chan []byte

	sync.Mutex
	// contains filtered or unexported fields
}

A pool of clients

func NewPool

func NewPool() *Pool

Create a new pool of clients

func (*Pool) ClientExists

func (c *Pool) ClientExists(instanceID string) bool

Check if a client exists in the pool using the client id

func (*Pool) Close

func (c *Pool) Close()

close the pool

func (*Pool) DeleteClient

func (c *Pool) DeleteClient(instanceID string) error

Delete a client from the pool

func (*Pool) GetClient

func (c *Pool) GetClient(instanceID string) (*Instance, error)

Get a client from the pool using the client id

func (*Pool) GetClients

func (c *Pool) GetClients() map[string]*Instance

Get all clients in a pool

func (*Pool) NewClient

func (c *Pool) NewClient(instance *Instance) error

Add new client to pool

func (*Pool) Start

func (c *Pool) Start()

Start a pool -

func (*Pool) StartClient

func (c *Pool) StartClient(instanceID string) error

Start a pool client

Jump to

Keyboard shortcuts

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