refactoring stuff into libraries
parent
13fdf6160c
commit
eaeb4b7ea7
@ -0,0 +1,50 @@
|
||||
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"
|
||||
|
||||
"code.ndumas.com/ndumas/gomud/telnet"
|
||||
)
|
||||
|
||||
func main() {
|
||||
l, err := net.Listen("tcp", ":5555")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer l.Close()
|
||||
wmLogger := watermill.NewStdLogger(false, false)
|
||||
|
||||
logger := NewWrappedSlogger()
|
||||
router, err := message.NewRouter(message.RouterConfig{}, logger)
|
||||
|
||||
router.AddPlugin(plugin.SignalsHandler)
|
||||
|
||||
router.AddMiddleware(
|
||||
middleware.CorrelationID,
|
||||
middleware.Recoverer,
|
||||
)
|
||||
|
||||
pubSub := gochannel.NewGoChannel(gochannel.Config{}, wmLogger)
|
||||
|
||||
ctx := context.Background()
|
||||
ts := telnet.NewTELNETServer(ctx, l, pubSub, logger)
|
||||
tp := telnet.NewTELNETParser(ctx, pubSub, logger)
|
||||
go tp.Handle()
|
||||
|
||||
for {
|
||||
conn, err := ts.l.Accept()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
go ts.Handle(conn)
|
||||
}
|
||||
}
|
@ -1 +0,0 @@
|
||||
package protocol
|
Loading…
Reference in New Issue