conns

package
v1.6.4 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2017 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultDisconnectAdvice = &DisconnectAdvice{Reason: "", Reconnect: true}

DefaultDisconnectAdvice is no reason and reconnect.

View Source
var (
	// ShutdownSemaphoreChanBufferSize limits graceful disconnects concurrency on
	// node shutdown.
	ShutdownSemaphoreChanBufferSize = 1000
)

Functions

This section is empty.

Types

type AdminConn

type AdminConn interface {
	// UID returns unique admin connection id.
	UID() string
	// Handle message coming from admin client.
	Handle(message []byte) error
	// Send allows to send message to admin connection.
	Send(message []byte) error
	// Close closes admin's connection.
	Close(*DisconnectAdvice) error
}

AdminConn is an interface abstracting all methods used by application to interact with admin connection.

type AdminHub

type AdminHub interface {
	Add(c AdminConn) error
	Remove(c AdminConn) error
	NumAdmins() int
	Broadcast(message []byte) error
	Shutdown() error
}

AdminHub is an interface describing admin connections to node.

func NewAdminHub

func NewAdminHub() AdminHub

NewAdminHub initializes new adminHub.

type ClientConn

type ClientConn interface {
	// UID returns unique connection id.
	UID() string
	// User return user ID associated with connection.
	User() string
	// Channels returns a slice of channels connection subscribed to.
	Channels() []string
	// Handle message coming from client.
	Handle(message []byte) error
	// Send allows to send message to connection client.
	Send(message []byte) error
	// Unsubscribe allows to unsubscribe connection from channel.
	Unsubscribe(ch string) error
	// Close closes client's connection.
	Close(*DisconnectAdvice) error
}

ClientConn is an interface abstracting all methods used by application to interact with client connection.

type ClientHub

type ClientHub interface {
	Add(c ClientConn) error
	Remove(c ClientConn) error
	AddSub(ch string, c ClientConn) (bool, error)
	RemoveSub(ch string, c ClientConn) (bool, error)
	Broadcast(ch string, message []byte) error
	NumSubscribers(ch string) int
	NumClients() int
	NumUniqueClients() int
	NumChannels() int
	Channels() []string
	UserConnections(user string) map[string]ClientConn
	Shutdown() error
}

ClientHub is an interface describing current client connections to node.

func NewClientHub

func NewClientHub() ClientHub

NewClientHub initializes clientHub.

type DisconnectAdvice

type DisconnectAdvice struct {
	Reason    string `json:"reason"`
	Reconnect bool   `json:"reconnect"`
	// contains filtered or unexported fields
}

DisconnectAdvice sent to client when we want it to gracefully disconnect.

func (*DisconnectAdvice) JSONString

func (a *DisconnectAdvice) JSONString() (string, error)

JSONString contains cached representation of DisconnectAdvice as JSON.

type Session

type Session interface {
	// Send sends one message to session
	Send([]byte) error
	// Close closes the session with provided code and reason.
	Close(*DisconnectAdvice) error
}

Session represents a connection transport between server and client.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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