conns

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2016 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultDisconnectAdvice = &DisconnectAdvice{Reason: "", Reconnect: true}
View Source
var (
	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
}

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
}

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
}

func (*DisconnectAdvice) JSONString

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

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