Wait for server comfirmation before updating nick

This commit is contained in:
Ken-Håvard Lieng 2017-04-13 01:50:58 +02:00
parent 1739b15eaa
commit b2e3e995ce
5 changed files with 36 additions and 29 deletions

View file

@ -191,15 +191,12 @@ func (c *Client) recv() {
}
case ReplyWelcome:
c.setNick(msg.Params[0])
c.once.Do(c.ready.Done)
case ErrNicknameInUse:
if c.HandleNickInUse != nil {
newNick := c.HandleNickInUse(msg.Params[1])
// Set the nick here aswell incase this happens during registration
// since there will be no NICK message to confirm it then
c.setNick(newNick)
go c.writeNick(newNick)
go c.writeNick(c.HandleNickInUse(msg.Params[1]))
}
}