mirror of
https://github.com/CPunch/gopenfusion.git
synced 2024-11-12 19:20:06 +00:00
CPunch
f4b17906ce
- 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
43 lines
885 B
Go
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
|
|
}
|