mirror of
https://github.com/CPunch/gopenfusion.git
synced 2024-11-14 03:50:05 +00:00
CPunch
1f66acfd25
started out as me making a service abstraction.. - db.Player exists again, and entity.Player uses it as an embedded struct - chunk.ForEachEntity() lets you add/remove entities during iteration now - removed account related fields from CNPeer - protocol/pool has been merged with protocol. use protocol.GetBuffer() and protocol.PutBuffer(). - new protocol/internal/service! service.Service is an abstraction layer to handle multiple CNPeer* connections and allows you to associate each with an interface{} uData. In the future it might also handle a task queue for jobs that modify/interact with the player's uData, called from service.handleEvents() - PacketHandler callback type has a new param! uData is passed as well now - much of loginserver/shardserver is now handled by the shared service abstraction - SHARD: NPC_ENTER packets are now sent on player loading complete rather than on enter.
53 lines
1.9 KiB
Go
53 lines
1.9 KiB
Go
package login
|
|
|
|
import (
|
|
"github.com/CPunch/gopenfusion/internal/db"
|
|
"github.com/CPunch/gopenfusion/internal/protocol"
|
|
"github.com/CPunch/gopenfusion/internal/redis"
|
|
"github.com/CPunch/gopenfusion/internal/service"
|
|
)
|
|
|
|
type LoginServer struct {
|
|
service *service.Service
|
|
dbHndlr *db.DBHandler
|
|
redisHndlr *redis.RedisHandler
|
|
}
|
|
|
|
func NewLoginServer(dbHndlr *db.DBHandler, redisHndlr *redis.RedisHandler, port int) (*LoginServer, error) {
|
|
srvc, err := service.NewService("LOGIN", port)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
server := &LoginServer{
|
|
service: srvc,
|
|
dbHndlr: dbHndlr,
|
|
redisHndlr: redisHndlr,
|
|
}
|
|
|
|
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)
|
|
|
|
srvc.OnConnect = func(peer *protocol.CNPeer) interface{} {
|
|
return nil
|
|
}
|
|
|
|
return server, nil
|
|
}
|
|
|
|
func (server *LoginServer) Start() {
|
|
server.service.Start()
|
|
}
|