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-12-02 01:22:49 +00:00
|
|
|
"github.com/CPunch/gopenfusion/cnet"
|
2023-12-02 01:56:23 +00:00
|
|
|
"github.com/CPunch/gopenfusion/cnet/protocol"
|
2023-08-23 23:16:24 +00:00
|
|
|
"github.com/CPunch/gopenfusion/internal/db"
|
|
|
|
"github.com/CPunch/gopenfusion/internal/redis"
|
2023-03-07 20:47:49 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type LoginServer struct {
|
2023-12-02 01:22:49 +00:00
|
|
|
service *cnet.Service
|
2023-11-28 03:23:28 +00:00
|
|
|
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) {
|
2023-12-02 01:22:49 +00:00
|
|
|
srvc := cnet.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)
|
2023-12-02 01:22:49 +00:00
|
|
|
srvc.AddPacketHandler(protocol.P_CL2LS_REQ_SHARD_SELECT, cnet.StubbedPacket)
|
|
|
|
srvc.AddPacketHandler(protocol.P_CL2LS_REQ_SHARD_LIST_INFO, cnet.StubbedPacket)
|
|
|
|
srvc.AddPacketHandler(protocol.P_CL2LS_CHECK_NAME_LIST, cnet.StubbedPacket)
|
2023-11-28 03:23:28 +00:00
|
|
|
srvc.AddPacketHandler(protocol.P_CL2LS_REQ_SAVE_CHAR_TUTOR, server.FinishTutorial)
|
2023-12-02 01:22:49 +00:00
|
|
|
srvc.AddPacketHandler(protocol.P_CL2LS_REQ_PC_EXIT_DUPLICATE, cnet.StubbedPacket)
|
|
|
|
srvc.AddPacketHandler(protocol.P_CL2LS_REP_LIVE_CHECK, cnet.StubbedPacket)
|
|
|
|
srvc.AddPacketHandler(protocol.P_CL2LS_REQ_CHANGE_CHAR_NAME, cnet.StubbedPacket)
|
|
|
|
srvc.AddPacketHandler(protocol.P_CL2LS_REQ_SERVER_SELECT, cnet.StubbedPacket)
|
2023-11-28 03:23:28 +00:00
|
|
|
|
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
|
|
|
}
|