2023-03-27 22:02:13 +00:00
|
|
|
package login
|
2023-03-07 20:47:49 +00:00
|
|
|
|
|
|
|
import (
|
2023-12-01 06:56:34 +00:00
|
|
|
"context"
|
|
|
|
|
2023-08-23 23:16:24 +00:00
|
|
|
"github.com/CPunch/gopenfusion/internal/db"
|
|
|
|
"github.com/CPunch/gopenfusion/internal/protocol"
|
|
|
|
"github.com/CPunch/gopenfusion/internal/redis"
|
2023-11-28 03:23:28 +00:00
|
|
|
"github.com/CPunch/gopenfusion/internal/service"
|
2023-03-07 20:47:49 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type LoginServer struct {
|
2023-11-28 03:23:28 +00:00
|
|
|
service *service.Service
|
|
|
|
dbHndlr *db.DBHandler
|
|
|
|
redisHndlr *redis.RedisHandler
|
2023-03-07 20:47:49 +00:00
|
|
|
}
|
|
|
|
|
2023-12-01 06:56:34 +00:00
|
|
|
func NewLoginServer(ctx context.Context, dbHndlr *db.DBHandler, redisHndlr *redis.RedisHandler, port int) (*LoginServer, error) {
|
|
|
|
srvc := service.NewService(ctx, "LOGIN", port)
|
2023-03-07 20:47:49 +00:00
|
|
|
|
2023-03-17 21:27:47 +00:00
|
|
|
server := &LoginServer{
|
2023-11-28 03:23:28 +00:00
|
|
|
service: srvc,
|
2023-06-22 06:53:38 +00:00
|
|
|
dbHndlr: dbHndlr,
|
|
|
|
redisHndlr: redisHndlr,
|
2023-03-07 20:47:49 +00:00
|
|
|
}
|
2023-03-11 02:30:16 +00:00
|
|
|
|
2023-11-28 03:23:28 +00:00
|
|
|
srvc.AddPacketHandler(protocol.P_CL2LS_REQ_LOGIN, server.Login)
|
|
|
|
srvc.AddPacketHandler(protocol.P_CL2LS_REQ_CHECK_CHAR_NAME, server.CheckCharacterName)
|
|
|
|
srvc.AddPacketHandler(protocol.P_CL2LS_REQ_SAVE_CHAR_NAME, server.SaveCharacterName)
|
|
|
|
srvc.AddPacketHandler(protocol.P_CL2LS_REQ_CHAR_CREATE, server.CharacterCreate)
|
|
|
|
srvc.AddPacketHandler(protocol.P_CL2LS_REQ_CHAR_SELECT, server.ShardSelect)
|
|
|
|
srvc.AddPacketHandler(protocol.P_CL2LS_REQ_CHAR_DELETE, server.CharacterDelete)
|
|
|
|
srvc.AddPacketHandler(protocol.P_CL2LS_REQ_SHARD_SELECT, service.StubbedPacket)
|
|
|
|
srvc.AddPacketHandler(protocol.P_CL2LS_REQ_SHARD_LIST_INFO, service.StubbedPacket)
|
|
|
|
srvc.AddPacketHandler(protocol.P_CL2LS_CHECK_NAME_LIST, service.StubbedPacket)
|
|
|
|
srvc.AddPacketHandler(protocol.P_CL2LS_REQ_SAVE_CHAR_TUTOR, server.FinishTutorial)
|
|
|
|
srvc.AddPacketHandler(protocol.P_CL2LS_REQ_PC_EXIT_DUPLICATE, service.StubbedPacket)
|
|
|
|
srvc.AddPacketHandler(protocol.P_CL2LS_REP_LIVE_CHECK, service.StubbedPacket)
|
|
|
|
srvc.AddPacketHandler(protocol.P_CL2LS_REQ_CHANGE_CHAR_NAME, service.StubbedPacket)
|
|
|
|
srvc.AddPacketHandler(protocol.P_CL2LS_REQ_SERVER_SELECT, service.StubbedPacket)
|
|
|
|
|
2023-03-17 21:27:47 +00:00
|
|
|
return server, nil
|
2023-03-07 20:47:49 +00:00
|
|
|
}
|
|
|
|
|
2023-11-30 01:57:45 +00:00
|
|
|
func (server *LoginServer) Start() error {
|
|
|
|
return server.service.Start()
|
2023-03-07 20:47:49 +00:00
|
|
|
}
|