Add IRC connection status indicator

This commit is contained in:
Ken-Håvard Lieng 2016-01-13 18:53:54 +01:00
parent 83aef5df7b
commit f429a528ba
11 changed files with 124 additions and 38 deletions

View file

@ -10,6 +10,8 @@ import (
)
func (c *Client) Connect(address string) {
c.ConnectionChanged <- false
if idx := strings.Index(address, ":"); idx < 0 {
c.Host = address
@ -70,6 +72,7 @@ func (c *Client) connect() error {
}
c.connected = true
c.ConnectionChanged <- true
c.reader = bufio.NewReader(c.conn)
c.register()
@ -154,6 +157,7 @@ func (c *Client) recv() {
return
default:
c.ConnectionChanged <- false
c.lock.Lock()
c.connected = false
c.lock.Unlock()
@ -181,6 +185,7 @@ func (c *Client) recv() {
func (c *Client) close() {
if c.Connected() {
c.ConnectionChanged <- false
c.lock.Lock()
c.connected = false
c.lock.Unlock()