mirror of
				https://github.com/fluffle/goirc
				synced 2025-11-04 12:08:03 +00:00 
			
		
		
		
	Update example client.
This commit is contained in:
		
							parent
							
								
									3e1b2c0f81
								
							
						
					
					
						commit
						d119e6bca0
					
				
					 1 changed files with 7 additions and 17 deletions
				
			
		
							
								
								
									
										20
									
								
								client.go
									
										
									
									
									
								
							
							
						
						
									
										20
									
								
								client.go
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -20,12 +20,6 @@ func main() {
 | 
			
		|||
	c.AddHandler("disconnected",
 | 
			
		||||
		func(conn *irc.Conn, line *irc.Line) { quit <- true })
 | 
			
		||||
 | 
			
		||||
	// connect to server
 | 
			
		||||
	if err := c.Connect("irc.freenode.net"); err != nil {
 | 
			
		||||
		fmt.Printf("Connection error: %s\n", err)
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// set up a goroutine to read commands from stdin
 | 
			
		||||
	in := make(chan string, 4)
 | 
			
		||||
	reallyquit := false
 | 
			
		||||
| 
						 | 
				
			
			@ -80,17 +74,13 @@ func main() {
 | 
			
		|||
	}()
 | 
			
		||||
 | 
			
		||||
	for !reallyquit {
 | 
			
		||||
		select {
 | 
			
		||||
		case err := <-c.Err:
 | 
			
		||||
			fmt.Printf("goirc error: %s\n", err)
 | 
			
		||||
		case <-quit:
 | 
			
		||||
			if !reallyquit {
 | 
			
		||||
				fmt.Println("Reconnecting...")
 | 
			
		||||
		// connect to server
 | 
			
		||||
		if err := c.Connect("irc.freenode.net"); err != nil {
 | 
			
		||||
			fmt.Printf("Connection error: %s\n", err)
 | 
			
		||||
					reallyquit = true
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			return
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// wait on quit channel
 | 
			
		||||
		<-quit
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue