You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gomud/cmd/echo/server.go

47 lines
950 B
Go

package main
import (
"context"
"log"
"net"
"github.com/ThreeDotsLabs/watermill"
"github.com/ThreeDotsLabs/watermill/message"
"github.com/ThreeDotsLabs/watermill/message/router/middleware"
"github.com/ThreeDotsLabs/watermill/message/router/plugin"
"github.com/ThreeDotsLabs/watermill/pubsub/gochannel"
)
func main() {
l, err := net.Listen("tcp", ":5555")
if err != nil {
log.Fatal(err)
}
defer l.Close()
wmLogger := watermill.NewStdLogger(false, false)
router, err := message.NewRouter(message.RouterConfig{}, wmLogger)
router.AddPlugin(plugin.SignalsHandler)
router.AddMiddleware(
middleware.CorrelationID,
middleware.Recoverer,
)
pubSub := gochannel.NewGoChannel(gochannel.Config{}, wmLogger)
ctx := context.Background()
ts := NewTELNETServer(ctx, l, pubSub)
tp := NewTELNETParser(ctx, pubSub)
go tp.Handle()
for {
conn, err := ts.l.Accept()
if err != nil {
log.Fatal(err)
}
go ts.Handle(conn)
}
}