diff --git a/cmd/echo.go b/cmd/echo.go new file mode 100644 index 0000000..d36399e --- /dev/null +++ b/cmd/echo.go @@ -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) + } +} diff --git a/go.mod b/go.mod index d29a79c..f42edd5 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,7 @@ module code.ndumas.com/ndumas/gomud go 1.19 + +require github.com/therealfakemoot/go-telnet v0.0.0-20230818185913-4f336ab6b975 + +require github.com/reiver/go-oi v1.0.0 // indirect diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..89546dd --- /dev/null +++ b/go.sum @@ -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= diff --git a/protocol/telnet.go b/protocol/telnet.go new file mode 100644 index 0000000..2d0eaff --- /dev/null +++ b/protocol/telnet.go @@ -0,0 +1 @@ +package protocol