Documentation ¶
Index ¶
- Variables
- type Chat
- func (chat *Chat) Close() error
- func (chat *Chat) Printf(format string, a ...interface{})
- func (chat *Chat) Println(a ...interface{})
- func (chat *Chat) Subscribe(s Subscriber)
- func (chat *Chat) Unsubscribe(s Subscriber)
- func (chat *Chat) Write(p []byte) (n int, err error)
- func (chat *Chat) WriteString(s string) (n int, err error)
- type StdoutSubscriber
- type Subscriber
Constants ¶
This section is empty.
Variables ¶
var Global = New()
Global represents a global chat. Players will write in this chat by default when they send any message in the chat.
Functions ¶
This section is empty.
Types ¶
type Chat ¶
type Chat struct {
// contains filtered or unexported fields
}
Chat represents the in-game chat. Messages may be written to it to send a message to all subscribers. The zero value of Chat is a chat ready to use. Methods on Chat may be called from multiple goroutines concurrently.
func New ¶
func New() *Chat
New returns a new chat. A zero value is, however, usually sufficient for use.
func (*Chat) Printf ¶
Printf prints a formatted message using a specific format to the chat. The message is formatted according to the fmt.Sprintf formatting rules.
func (*Chat) Println ¶
func (chat *Chat) Println(a ...interface{})
Println prints a formatted message to the chat. The message is formatted according to the fmt.Sprintln formatting rules.
func (*Chat) Subscribe ¶
func (chat *Chat) Subscribe(s Subscriber)
Subscribe adds a subscriber to the chat, sending it every message written to the chat. In order to remove it again, use Chat.Unsubscribe().
func (*Chat) Unsubscribe ¶
func (chat *Chat) Unsubscribe(s Subscriber)
Unsubscribe removes a subscriber from the chat, so that messages written to the chat will no longer be sent to it.
type StdoutSubscriber ¶
type StdoutSubscriber struct{}
StdoutSubscriber is an implementation of Subscriber that forwards messages sent to the chat to the stdout.
type Subscriber ¶
type Subscriber interface { // Message sends a formatted message to the subscriber. The message is formatted as it would when using // fmt.Println. Message(a ...interface{}) }
Subscriber represents an entity that may subscribe to a Chat. In order to do so, the Subscriber must implement methods to send messages to it.