Documentation ¶
Index ¶
- Variables
- type Client
- type Error
- type ErrorSeverity
- type Message
- type Room
- func (r *Room) AddClient(u *user.User, ws *websocket.Conn) error
- func (r *Room) AddMessage(m *Message)
- func (r *Room) GetClient(id xid.ID) (*Client, bool)
- func (r *Room) IsAtCapacity() bool
- func (r *Room) IterateClients(fn func(u *user.User, conn *websocket.Conn) error)
- func (r *Room) Messages() []*Message
- func (r *Room) NumUsers() uint64
- func (r *Room) RemoveClient(id xid.ID) bool
- func (r *Room) Write(p []byte) (int, error)
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrLoading = NewError(ErrorSeverityWarning, true, "loading...") ErrUnknown = NewError(ErrorSeverityError, false, "unknown error") ErrRateLimited = NewError(ErrorSeverityWarning, false, "please slow down") ErrMessageEmpty = NewError(ErrorSeverityError, false, "message content cannot be empty") ErrExistingSession = NewError(ErrorSeverityError, true, "you already have a running session for this room") ErrRoomFull = NewError(ErrorSeverityError, true, "the room is full") )
List of chat errors.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client represents the relationship between a user and websocket connections.
type Error ¶ added in v0.2.0
type Error struct {
// contains filtered or unexported fields
}
Error represents a chat error.
func NewError ¶ added in v0.2.0
func NewError(s ErrorSeverity, global bool, err string) Error
NewError creates a new Error.
type ErrorSeverity ¶ added in v0.2.0
type ErrorSeverity uint8
ErrorSeverity is the severity of an error.
const ( ErrorSeverityWarning ErrorSeverity = iota ErrorSeverityError )
List of chat errors.
type Room ¶
type Room struct {
// contains filtered or unexported fields
}
Room holds the state of a single chat room.
func (*Room) IsAtCapacity ¶ added in v0.2.0
IsAtCapacity returns true if the room is at capacity.
func (*Room) IterateClients ¶
IterateClients executes a function fn (e.g. a custom send mechanism or personalized messages per client) for all the clients.
func (*Room) RemoveClient ¶
RemoveClient removes a client.
Click to show internal directories.
Click to hide internal directories.