Stage object notification test

This commit is contained in:
Andrew Gutekanst
2020-01-23 19:59:26 -05:00
parent 28e0dafd54
commit b1b4f390f0
4 changed files with 43 additions and 8 deletions

View File

@@ -301,8 +301,35 @@ func handleMsgSysEnterStage(s *Session, p mhfpacket.MHFPacket) {
s.QueueAck(pkt.AckHandle, []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})
// TODO(Andoryuuta): Notify existing stage clients that this new client has entered.
// TODO(Andoryuuta): Notify this client about all of the existing clients in the stage.
insertUserPkt := &mhfpacket.MsgSysInsertUser{
CharID: s.charID,
}
s.stage.BroadcastMHF(insertUserPkt, s)
// Just the first user binary type (name) for right now.
notifyUserBinary1Pkt := &mhfpacket.MsgSysNotifyUserBinary{
CharID: s.charID,
BinaryType: 1,
}
s.stage.BroadcastMHF(notifyUserBinary1Pkt, s)
// TODO(Andoryuuta): Notify this client about all of the existing clients in the stage.
s.stage.RLock()
clientNotif := byteframe.NewByteFrame()
for session := range s.stage.clients {
(&mhfpacket.MsgSysInsertUser{
CharID: session.charID,
}).Build(clientNotif)
// Just the first user binary type (name) for right now.
(&mhfpacket.MsgSysNotifyUserBinary{
CharID: session.charID,
BinaryType: 1,
}).Build(clientNotif)
}
s.stage.RUnlock()
s.QueueSend(clientNotif.Data())
}
func handleMsgSysBackStage(s *Session, p mhfpacket.MHFPacket) {}

View File

@@ -29,7 +29,7 @@ type Session struct {
// NewSession creates a new Session type.
func NewSession(server *Server, conn net.Conn) *Session {
s := &Session{
logger: server.logger,
logger: server.logger.Named(conn.RemoteAddr().String()),
server: server,
rawConn: conn,
cryptConn: network.NewCryptConn(conn),