chat

package
v0.0.0-...-6b8f2fb Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2015 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Timestamp func() string = _timestamp

overwritable for testing

Functions

This section is empty.

Types

type ChatManager

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

ChatManager keeps track of clients connected to the chat service and is responsible for communications between them.

func NewChatManager

func NewChatManager(chatLog io.Writer, maxHistoryLines int) *ChatManager

NewChatManager returns an initialized ChatManager

func (*ChatManager) Broadcast

func (c *ChatManager) Broadcast(name string, msg []byte)

Broadcast writes msg to all clients known to the ChatManager.

func (*ChatManager) History

func (c *ChatManager) History(numLines int) []byte

History returns the specifies number of lines (numLines) from the chat history as a slices of bytes.

func (*ChatManager) Join

func (c *ChatManager) Join(name string, conn net.Conn) error

Join adds a user to the chat manager and announces the join to all clients.

func (*ChatManager) Quit

func (c *ChatManager) Quit(name string)

Quit removes a user from the chat manager and announces the quit to all clients.

Jump to

Keyboard shortcuts

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