mirror of https://github.com/fluffle/goirc
Split Connect() into two pieces for testing purposes.
This commit is contained in:
parent
a95da1cb2c
commit
045679dd42
|
@ -143,26 +143,29 @@ func (conn *Conn) Connect(host string, pass ...string) os.Error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
conn.Host = host
|
conn.Host = host
|
||||||
conn.io = bufio.NewReadWriter(
|
|
||||||
bufio.NewReader(conn.sock),
|
|
||||||
bufio.NewWriter(conn.sock))
|
|
||||||
conn.sock.SetTimeout(conn.Timeout * second)
|
|
||||||
conn.connected = true
|
conn.connected = true
|
||||||
go conn.send()
|
conn.postConnect()
|
||||||
go conn.recv()
|
|
||||||
|
|
||||||
if len(pass) > 0 {
|
if len(pass) > 0 {
|
||||||
conn.Pass(pass[0])
|
conn.Pass(pass[0])
|
||||||
}
|
}
|
||||||
conn.Nick(conn.Me.Nick)
|
conn.Nick(conn.Me.Nick)
|
||||||
conn.User(conn.Me.Ident, conn.Me.Name)
|
conn.User(conn.Me.Ident, conn.Me.Name)
|
||||||
|
|
||||||
go conn.runLoop()
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Post-connection setup (for ease of testing)
|
||||||
|
func (conn *Conn) postConnect() {
|
||||||
|
conn.io = bufio.NewReadWriter(
|
||||||
|
bufio.NewReader(conn.sock),
|
||||||
|
bufio.NewWriter(conn.sock))
|
||||||
|
conn.sock.SetTimeout(conn.Timeout * second)
|
||||||
|
go conn.send()
|
||||||
|
go conn.recv()
|
||||||
|
go conn.runLoop()
|
||||||
|
}
|
||||||
|
|
||||||
// dispatch a nicely formatted os.Error to the error channel
|
// dispatch a nicely formatted os.Error to the error channel
|
||||||
func (conn *Conn) error(s string, a ...interface{}) {
|
func (conn *Conn) error(s string, a ...interface{}) {
|
||||||
conn.Err <- os.NewError(fmt.Sprintf(s, a...))
|
conn.Err <- os.NewError(fmt.Sprintf(s, a...))
|
||||||
|
|
Loading…
Reference in New Issue