Update the docs slightly.

This commit is contained in:
Alex Bramley 2011-07-22 01:26:41 +01:00
parent c3715be829
commit 830dbcbb7f
1 changed files with 13 additions and 7 deletions

View File

@ -25,14 +25,20 @@ Synopsis:
c.Debug = true c.Debug = true
// Optionally, enable SSL // Optionally, enable SSL
c.SSL = true c.SSL = true
// add handlers to do things here!
if err := c.Connect("irc.freenode.net"); err != nil { // Add handlers to do things here!
// e.g. watching for disconnection from the server.
connected := true
c.AddHandler("disconnected",
func(conn *irc.Conn, line *irc.Line) { connected = false })
// Tell client to connect
if err := c.Connect("irc.freenode.net"); err != nil {
fmt.Printf("Connection error: %s\n", err.String()) fmt.Printf("Connection error: %s\n", err.String())
} }
for {
if closed(c.Err) { // Loop until client gets disconnected, printing any errors
break for connected {
}
if err := <-c.Err; err != nil { if err := <-c.Err; err != nil {
fmt.Printf("goirc error: %s", err.String()) fmt.Printf("goirc error: %s", err.String())
} }
@ -61,5 +67,5 @@ indebted to Matt Gruen for his work on
the re-organisation and channel-based communication structure of `*Conn.send()` the re-organisation and channel-based communication structure of `*Conn.send()`
and `*Conn.recv()`. I'm sure things could be more asynchronous, still. and `*Conn.recv()`. I'm sure things could be more asynchronous, still.
This code is (c) 2009-10 Alex Bramley, and released under the same licence terms This code is (c) 2009-11 Alex Bramley, and released under the same licence terms
as Go itself. as Go itself.