Skip to content

Commit cc25767

Browse files
committed
fixed: fixed an error that did not allow the application to run even after picking a nickname
1 parent f27f8ad commit cc25767

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

chat/chat

0 Bytes
Binary file not shown.

chat/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func (c *client) readInput() {
4242

4343
func (c *client) readCommand(cmd string, args []string) {
4444
log.Printf("command you entered: %s", cmd)
45-
if cmd != "/randomnick" && cmd != "/nick" && cmd != "/help" && cmd != "/quit" {
45+
if cmd != "/randomnick" && cmd != "/nick" && cmd != "/help" && cmd != "/quit" && c.nick == "anonymous" {
4646
c.err(fmt.Errorf("pick a new nickname, otherwise enter /randomnick"))
4747
} else {
4848
switch cmd {

chat/server.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,10 @@ func (s *server) newClient(conn net.Conn) {
4848
c.msg(fmt.Sprintf("type '/help' to see the list of commands.\n"))
4949
c.msg(fmt.Sprintf("type '/nick {nickname}' to assign a nickname to yourself.\n"))
5050
c.msg(fmt.Sprintf("If you want to pick a random nickname, type /randomnick"))
51-
// when a user creates a session, a nickname should be picked before
52-
// doing anything else
51+
52+
// // when a user creates a session, a nickname should be picked before
53+
// // doing anything else
54+
// new_session := true
5355
c.readInput()
5456
}
5557

0 commit comments

Comments
 (0)