game_sync/gatesrv/worldsessionclose.go

48 lines
1.1 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package main
import (
"mongo.games.com/goserver/core/logger"
"mongo.games.com/goserver/core/netlib"
"mongo.games.com/goserver/srvlib"
"mongo.games.com/goserver/srvlib/protocol"
)
/*
worldsrv关闭客户端连接都断开
*/
const (
WorldSessionCloseHandlerName = "handler-world-close"
)
type WorldSessionCloseHandler struct {
netlib.BasicSessionHandler
}
func (sfcl WorldSessionCloseHandler) GetName() string {
return WorldSessionCloseHandlerName
}
func (this *WorldSessionCloseHandler) GetInterestOps() uint {
return 1 << netlib.InterestOps_Closed
}
func (this *WorldSessionCloseHandler) OnSessionClosed(s *netlib.Session) {
logger.Logger.Warn("WorldSessionCloseHandler OnSessionClosed ", s.Id)
//close all client session
param := s.GetAttribute(srvlib.SessionAttributeServerInfo)
if registePacket, ok := param.(*protocol.SSSrvRegiste); ok {
if registePacket.GetType() == srvlib.WorldServiceType {
srvlib.ClientSessionMgrSington.CloseAll()
}
}
return
}
func init() {
netlib.RegisteSessionHandlerCreator(WorldSessionCloseHandlerName, func() netlib.SessionHandler {
return &WorldSessionCloseHandler{}
})
}