diff options
author | Kevin Chabowski <kevin@kch42.de> | 2014-03-25 14:08:06 +0100 |
---|---|---|
committer | Kevin Chabowski <kevin@kch42.de> | 2014-03-25 14:08:06 +0100 |
commit | 734f6e92016ca875ad56ff7e423a0872648c012f (patch) | |
tree | b753861d68e32462af5d8cab445b77b9abcede0b | |
parent | 472848fc93accb200ea2dedc46fdaa4e5d71d266 (diff) | |
download | simplechat-734f6e92016ca875ad56ff7e423a0872648c012f.tar.gz simplechat-734f6e92016ca875ad56ff7e423a0872648c012f.tar.bz2 simplechat-734f6e92016ca875ad56ff7e423a0872648c012f.zip |
Fixed some compile errors
-rw-r--r-- | rooms.go | 19 |
1 files changed, 10 insertions, 9 deletions
@@ -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 } |