-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
The FreeChessClub Author(s)
committed
Jun 2, 2019
1 parent
5e3336f
commit 4e5d38d
Showing
8 changed files
with
217 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// Copyright © 2019 Free Chess Club <hi@freechess.club> | ||
// | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package main | ||
|
||
import ( | ||
"bufio" | ||
"fmt" | ||
"io" | ||
"log" | ||
"os" | ||
|
||
"github.com/freechessclub/icsgo" | ||
) | ||
|
||
func main() { | ||
// connect as guest to the FICS server | ||
client, err := icsgo.NewClient(&icsgo.Config{ | ||
DisableKeepAlive: true, | ||
DisableTimeseal: true, | ||
Debug: true, | ||
}, "freechess.org:5000", "guest", "") | ||
if err != nil { | ||
log.Fatalf("error creating new FICS client: %v", err) | ||
} | ||
|
||
done := make(chan struct{}) | ||
go func() { | ||
defer client.Destroy() | ||
for { | ||
select { | ||
default: | ||
msgs, err := client.Recv() | ||
if err == io.EOF { | ||
return | ||
} | ||
if err != nil { | ||
log.Fatalf("error receiving server output: %v", err) | ||
return | ||
} | ||
|
||
if msgs != nil { | ||
fmt.Printf("%v\n", msgs) | ||
} | ||
case <-done: | ||
return | ||
} | ||
} | ||
}() | ||
|
||
reader := bufio.NewReader(os.Stdin) | ||
for { | ||
fmt.Print("fics_client% ") | ||
cmd, err := reader.ReadString('\n') | ||
if err != nil { | ||
client.Destroy() | ||
log.Fatalf("error reading console input: %v", err) | ||
} | ||
|
||
err = client.Send(cmd) | ||
if err != nil || cmd == "exit\n" { | ||
close(done) | ||
break | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.