diff options
author | Kevin Chabowski <kevin@kch42.de> | 2014-03-25 16:04:45 +0100 |
---|---|---|
committer | Kevin Chabowski <kevin@kch42.de> | 2014-03-25 16:04:45 +0100 |
commit | 96973a17b3e2301bb3d9f3b1d3f3c1b80f918fb1 (patch) | |
tree | 29e961eaf6df00158cdd9a69a327cf8bb829c707 /chat/buddy.go | |
parent | 966c17bb84866f10fc9e995df4107ed11ed2bdce (diff) | |
download | simplechat-96973a17b3e2301bb3d9f3b1d3f3c1b80f918fb1.tar.gz simplechat-96973a17b3e2301bb3d9f3b1d3f3c1b80f918fb1.tar.bz2 simplechat-96973a17b3e2301bb3d9f3b1d3f3c1b80f918fb1.zip |
Documenting the new chat package. Also fixing access rights
Diffstat (limited to 'chat/buddy.go')
-rw-r--r-- | chat/buddy.go | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/chat/buddy.go b/chat/buddy.go index c6f07ad..5b2308c 100644 --- a/chat/buddy.go +++ b/chat/buddy.go @@ -4,13 +4,15 @@ import ( "time" ) +// Buddy represents a user that participates in a chat. +// Read from the Receive channel to get incoming messages type Buddy struct { Nick string Receive chan Message room *Room } -func NewBuddy(nick string, room *Room) *Buddy { +func newBuddy(nick string, room *Room) *Buddy { return &Buddy{ Nick: nick, Receive: make(chan Message), @@ -18,10 +20,12 @@ func NewBuddy(nick string, room *Room) *Buddy { } } +// Leave will remove the buddy from the room. func (b *Buddy) Leave() { - b.room.Leave(b.Nick) + b.room.leave(b.Nick) } +// Push pushes a message to the buddies Receive channel func (b *Buddy) Push(msg Message) { go func() { select { @@ -33,7 +37,7 @@ func (b *Buddy) Push(msg Message) { // Say sends a text as a chat message of this user to the connected room. func (b *Buddy) Say(text string) { - b.room.Messages <- Message{ + b.room.messages <- Message{ Type: MsgChat, User: b.Nick, Text: text, |