40 lines
965 B
Go
40 lines
965 B
Go
package main
|
|
|
|
import (
|
|
"mongo.games.com/goserver/core/netlib"
|
|
"mongo.games.com/goserver/srvlib"
|
|
"mongo.games.com/goserver/srvlib/protocol"
|
|
)
|
|
|
|
func init() {
|
|
netlib.Register(int(protocol.SrvlibPacketID_PACKET_SS_MULTICAST), &protocol.SSPacketMulticast{}, MulticastHandler)
|
|
}
|
|
|
|
func MulticastHandler(s *netlib.Session, packetid int, data interface{}) error {
|
|
if mp, ok := data.(*protocol.SSPacketMulticast); ok {
|
|
pd := mp.GetData()
|
|
sis := mp.GetSessions()
|
|
for _, si := range sis {
|
|
ns := getSession(si)
|
|
if ns != nil {
|
|
ns.Send(int(mp.GetPacketId()), pd /*, s.GetSessionConfig().IsInnerLink*/)
|
|
}
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func getSession(su *protocol.MCSessionUnion) *netlib.Session {
|
|
cs := su.GetMccs()
|
|
if cs != nil {
|
|
return srvlib.ClientSessionMgrSington.GetSession(cs.GetSId())
|
|
}
|
|
|
|
ss := su.GetMcss()
|
|
if ss != nil {
|
|
return srvlib.ServerSessionMgrSington.GetSession(int(ss.GetSArea()), int(ss.GetSType()), int(ss.GetSId()))
|
|
}
|
|
|
|
return nil
|
|
}
|