drafting a telnet echo

main
Nick Dumas 1 year ago
parent 549c52b20f
commit 0ff68c5f5e

@ -0,0 +1,30 @@
package main
import (
"bufio"
"fmt"
"github.com/therealfakemoot/go-telnet"
)
type MUDHandler struct {
}
func (mh MUDHandler) ServeTELNET(ctx telnet.Context, w telnet.Writer, r telnet.Reader) {
s := bufio.NewScanner(r)
// s.Split(bufio.ScanWords)
for s.Scan() {
fmt.Printf("Received user input: %q\n", s.Text())
}
}
func main() {
var handler telnet.Handler = MUDHandler{}
err := telnet.ListenAndServe(":5555", handler)
if nil != err {
//@TODO: Handle this error better.
panic(err)
}
}

@ -1,3 +1,7 @@
module code.ndumas.com/ndumas/gomud module code.ndumas.com/ndumas/gomud
go 1.19 go 1.19
require github.com/therealfakemoot/go-telnet v0.0.0-20230818185913-4f336ab6b975
require github.com/reiver/go-oi v1.0.0 // indirect

@ -0,0 +1,4 @@
github.com/reiver/go-oi v1.0.0 h1:nvECWD7LF+vOs8leNGV/ww+F2iZKf3EYjYZ527turzM=
github.com/reiver/go-oi v1.0.0/go.mod h1:RrDBct90BAhoDTxB1fenZwfykqeGvhI6LsNfStJoEkI=
github.com/therealfakemoot/go-telnet v0.0.0-20230818185913-4f336ab6b975 h1:0ya9MAIQtQnj2zj4XA/lAkd/PHXCD1sIFh/vBMQxADM=
github.com/therealfakemoot/go-telnet v0.0.0-20230818185913-4f336ab6b975/go.mod h1:W73X7Jmde9dHeL8DTG7y3+F4fcPhyNt9HSLe/oyOX5U=

@ -0,0 +1 @@
package protocol
Loading…
Cancel
Save