Rejoin channels after reconnecting

This commit is contained in:
Ken-Håvard Lieng 2016-02-03 21:12:32 +01:00
parent 90b74ee022
commit 875f5fafe3
3 changed files with 35 additions and 1 deletions

View file

@ -22,7 +22,8 @@ type Client struct {
Messages chan *Message
ConnectionChanged chan bool
nick string
nick string
channels []string
conn net.Conn
connected bool
@ -149,3 +150,18 @@ func (c *Client) register() {
c.writeNick(c.nick)
c.writeUser(c.Username, c.Realname)
}
func (c *Client) addChannel(channel string) {
c.lock.Lock()
c.channels = append(c.channels, channel)
c.lock.Unlock()
}
func (c *Client) flushChannels() {
c.lock.Lock()
if len(c.channels) > 0 {
c.Join(c.channels...)
c.channels = []string{}
}
c.lock.Unlock()
}