From 734f6e92016ca875ad56ff7e423a0872648c012f Mon Sep 17 00:00:00 2001 From: Kevin Chabowski Date: Tue, 25 Mar 2014 14:08:06 +0100 Subject: Fixed some compile errors --- rooms.go | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'rooms.go') diff --git a/rooms.go b/rooms.go index 723fc98..ff441f2 100644 --- a/rooms.go +++ b/rooms.go @@ -6,14 +6,15 @@ import ( type Room struct { Messages chan Message - Buddies map[string]Buddy + Buddies map[string]*Buddy } func NewRoom() (r *Room) { r = new(Room) r.Messages = make(chan Message) - r.Buddies = make(map[string]Buddy) + r.Buddies = make(map[string]*Buddy) go r.Broadcast() + return } func (r *Room) Leave(nick string) { @@ -21,13 +22,13 @@ func (r *Room) Leave(nick string) { return } - delete(r.Buddies[nick]) + delete(r.Buddies, nick) if len(r.Buddies) == 0 { close(r.Messages) } else { r.Messages <- Message{ Type: MsgLeave, - From: nick, + User: nick, } } } @@ -47,7 +48,7 @@ func (r *Room) ListBuddies() (buddies []string) { return } -var rooms = make(map[string]Room) +var rooms = make(map[string]*Room) func Join(room, nick string) (*Buddy, *Room, error) { r, ok := rooms[room] @@ -57,19 +58,19 @@ func Join(room, nick string) (*Buddy, *Room, error) { } if _, there := r.Buddies[nick]; there { - return nil, room, errors.New("Nickname is already in use") + return nil, nil, errors.New("Nickname is already in use") } if len(r.Buddies) >= *perroom { - return nil, room, errors.New("Room is full") + return nil, nil, errors.New("Room is full") } r.Messages <- Message{ Type: MsgJoin, - From: nick, + User: nick, } b := NewBuddy(nick, r) r.Buddies[nick] = b - return b, nil + return b, r, nil } -- cgit v1.2.3-54-g00ecf