diff options
Diffstat (limited to 'chat/rooms.go')
-rw-r--r-- | chat/rooms.go | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/chat/rooms.go b/chat/rooms.go index 1991d77..793f027 100644 --- a/chat/rooms.go +++ b/chat/rooms.go @@ -7,6 +7,7 @@ import ( var ( NickAlreadyInUse = errors.New("Nickname is already in use") RoomIsFull = errors.New("Room is full") + EmptyNick = errors.New("Nickname must not be empty") ) // Room represents a chatroom. @@ -31,6 +32,7 @@ func (r *Room) leave(nick string) { } delete(r.buddies, nick) + if len(r.buddies) == 0 { close(r.messages) delete(rooms, r.name) @@ -81,6 +83,10 @@ func Join(room, nick string) (*Buddy, *Room, error) { return nil, nil, NickAlreadyInUse } + if nick == "" { + return nil, nil, EmptyNick + } + if len(r.buddies) >= perroom { return nil, nil, RoomIsFull } |