package base

import (
	"mongo.games.com/game/common"
	"mongo.games.com/goserver/core/logger"
	"mongo.games.com/goserver/core/netlib"
	"mongo.games.com/goserver/srvlib"
	"mongo.games.com/goserver/srvlib/protocol"
)

var WorldSessMgrSington = &WorldSessMgr{}

type WorldSessMgr struct {
}

func (this *WorldSessMgr) OnRegiste(s *netlib.Session) {

}

// 注册事件
func (this *WorldSessMgr) SendToMessage(packetid int, rawpack interface{}) {
	ss := srvlib.ServerSessionMgrSington.GetSession(common.GetSelfAreaId(), srvlib.WorldServerType, common.GetWorldSrvId())
	ss.Send(packetid, rawpack)
}

// 注销事件
func (this *WorldSessMgr) OnUnregiste(s *netlib.Session) {
	attr := s.GetAttribute(srvlib.SessionAttributeServerInfo)
	if attr != nil {
		if srvInfo, ok := attr.(*protocol.SSSrvRegiste); ok && srvInfo != nil {
			if srvInfo.GetType() == srvlib.WorldServiceType {
				logger.Logger.Warn("(this *WorldSessMgr) OnUnregiste (Srv):", s)
			}
		}
	}
}

func init() {
	srvlib.ServerSessionMgrSington.AddListener(WorldSessMgrSington)
}
