func (sess *Session) Ping() {
	msg := &protocol.MSG_MGR_PING{}
	sess.SendMsg(uint64(protocol.CMD_MGR_PING), msg)
}
Ping : ping
package nodenormal
import (
	"fmt"
	"sync/atomic"
	"time"
	go_redis_orm "github.com/fananchong/go-redis-orm.v2"
	"github.com/fananchong/go-xserver/common"
	"github.com/fananchong/go-xserver/common/config"
	"github.com/fananchong/go-xserver/common/context"
	nodecommon "github.com/fananchong/go-xserver/internal/components/node/common"
	"github.com/fananchong/go-xserver/internal/db"
	"github.com/fananchong/go-xserver/internal/protocol"
	"github.com/gomodule/redigo/redis"
)
type Session struct {
	*nodecommon.SessionBase
	GWMgr    *IntranetSessionMgr
	shutdown int32
}
func NewSession(ctx *common.Context) *Session {
	sess := &Session{}
	sess.SessionBase = nodecommon.NewSessionBase(ctx, sess)
	sess.SessMgr = nodecommon.NewSessionMgr(ctx)
	sess.GWMgr = NewIntranetSessionMgr(ctx)
	return sess
}
func (sess *Session) Start() bool {
	sess.GWMgr.Start()
	atomic.StoreInt32(&sess.shutdown, 0)
	sess.connectMgrServer()
	return true
}
func (sess *Session) connectMgrServer() {
	if shutdown := atomic.LoadInt32(&sess.shutdown); shutdown == 0 {
	TRY_AGAIN:
		addr, port := getMgrInfoByBlock(sess.Ctx)
		if sess.Connect(fmt.Sprintf("%s:%d", addr, port), sess) == false {
			time.Sleep(1 * time.Second)
			goto TRY_AGAIN
		}
		sess.Verify()
		sess.RegisterSelf(sess.GetID(), sess.GetType(), config.Mgr, &protocol.SERVER_ID{})
	}
}
func (sess *Session) DoRegister(msg *protocol.MSG_MGR_REGISTER_SERVER) {
	sess.Ctx.Infoln("The service node registers information with me with ID", msg.GetData().GetId().GetID(), "type:", msg.GetData().GetType())
	tempSess := sess.SessMgr.GetByID(nodecommon.ServerID2NodeID(msg.GetData().GetId()))
	if tempSess == nil {
		targetSess := NewIntranetSession(sess.Ctx, sess.SessMgr, sess)
		targetSess.Info = msg.GetData()
		targetSess.RegisterFuncOnRelayMsg(sess.FuncOnRelayMsg())
		targetSess.RegisterFuncOnLoseAccount(sess.FuncOnLoseAccount())
		sess.SessMgr.Register(targetSess.SessionBase)
		sess.PrintNodeInfo(sess.Ctx, config.NodeType(msg.GetData().GetType()))
		if sess.IsEnableMessageRelay() && targetSess.Info.GetType() == uint32(config.Gateway) {
			targetSess.Start()
		}
	} else {
		tempSess.Info = msg.GetData()
		sess.PrintNodeInfo(sess.Ctx, config.NodeType(msg.GetData().GetType()))
	}
}
func (sess *Session) DoVerify(msg *protocol.MSG_MGR_REGISTER_SERVER) {
}
func (sess *Session) DoLose(msg *protocol.MSG_MGR_LOSE_SERVER) {
	sess.Ctx.Infoln("Service node connection lost, ID is", msg.GetId().GetID(), "type:", msg.GetType())
	if sess.IsEnableMessageRelay() && msg.GetType() == uint32(config.Gateway) {
		targetSess := sess.SessMgr.GetByID(nodecommon.ServerID2NodeID(msg.GetId()))
		if targetSess != nil {
			targetSess.Close()
		}
	}
	sess.SessMgr.Lose2(msg.GetId(), config.NodeType(msg.GetType()))
	sess.PrintNodeInfo(sess.Ctx, config.NodeType(msg.GetType()))
}
func (sess *Session) DoClose(sessbase *nodecommon.SessionBase) {
	if sessbase.Info != nil {
		sess.SessMgr.Lose1(sessbase)
	}
	go func() {
		time.Sleep(1 * time.Second)
		sess.connectMgrServer()
	}()
}