gopenfusion/cmd/login.go
CPunch f4b17906ce more protocol/service refactor
- removed protocol.Event: CNPeers now send protocol.PacketEvents
- peer uData is held in CNPeer, use SetUserData() and UserData() to
set/read it
- Service.PacketHandler calback has changed, removed uData:
switched calls to peer.SetUserData() and peer.UserData() where appropriate
- service.Service lots of tidying up, removed dependence on old
protocol.Event.
- service.Service && protocol.CNPeer now accept a cancelable context.
hooray graceful shutdowns and unit tests!
- general cleanup
2023-12-01 00:56:34 -06:00

43 lines
885 B
Go

package main
import (
"context"
"flag"
"log"
"github.com/CPunch/gopenfusion/config"
"github.com/CPunch/gopenfusion/login"
"github.com/google/subcommands"
)
type loginCommand struct {
port int
}
func (s *loginCommand) Name() string {
return "login"
}
func (s *loginCommand) Synopsis() string {
return "Starts login service"
}
func (s *loginCommand) Usage() string {
return s.Name() + " - " + s.Synopsis() + ":\n"
}
func (s *loginCommand) SetFlags(f *flag.FlagSet) {
f.IntVar(&s.port, "port", config.LOGIN_PORT, "Hosts the service on this port")
}
func (s *loginCommand) Execute(ctx context.Context, f *flag.FlagSet, _ ...interface{}) subcommands.ExitStatus {
loginServer, err := login.NewLoginServer(ctx, dbHndlr, redisHndlr, s.port)
if err != nil {
log.Panicf("failed to create shard server: %v", err)
}
loginServer.Start()
return subcommands.ExitSuccess
}