diff --git a/network/mhfpacket/msg_sys_insert_user.go b/network/mhfpacket/msg_sys_insert_user.go index b8aa206e6..13466c493 100644 --- a/network/mhfpacket/msg_sys_insert_user.go +++ b/network/mhfpacket/msg_sys_insert_user.go @@ -6,7 +6,9 @@ import ( ) // MsgSysInsertUser represents the MSG_SYS_INSERT_USER -type MsgSysInsertUser struct{} +type MsgSysInsertUser struct { + CharID uint32 +} // Opcode returns the ID associated with this packet type. func (m *MsgSysInsertUser) Opcode() network.PacketID { @@ -20,5 +22,6 @@ func (m *MsgSysInsertUser) Parse(bf *byteframe.ByteFrame) error { // Build builds a binary packet from the current data. func (m *MsgSysInsertUser) Build(bf *byteframe.ByteFrame) error { - panic("Not implemented") -} \ No newline at end of file + bf.WriteUint32(m.CharID) + return nil +} diff --git a/network/mhfpacket/msg_sys_notify_user_binary.go b/network/mhfpacket/msg_sys_notify_user_binary.go index e4914aeef..2fbb5a9cf 100644 --- a/network/mhfpacket/msg_sys_notify_user_binary.go +++ b/network/mhfpacket/msg_sys_notify_user_binary.go @@ -6,7 +6,10 @@ import ( ) // MsgSysNotifyUserBinary represents the MSG_SYS_NOTIFY_USER_BINARY -type MsgSysNotifyUserBinary struct{} +type MsgSysNotifyUserBinary struct { + CharID uint32 + BinaryType uint8 +} // Opcode returns the ID associated with this packet type. func (m *MsgSysNotifyUserBinary) Opcode() network.PacketID { @@ -20,5 +23,7 @@ func (m *MsgSysNotifyUserBinary) Parse(bf *byteframe.ByteFrame) error { // Build builds a binary packet from the current data. func (m *MsgSysNotifyUserBinary) Build(bf *byteframe.ByteFrame) error { - panic("Not implemented") -} \ No newline at end of file + bf.WriteUint32(m.CharID) + bf.WriteUint8(m.BinaryType) + return nil +} diff --git a/server/channelserver/handlers.go b/server/channelserver/handlers.go index 1212dff55..4e8f196e3 100644 --- a/server/channelserver/handlers.go +++ b/server/channelserver/handlers.go @@ -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) {} diff --git a/server/channelserver/session.go b/server/channelserver/session.go index e41cb17dc..55afd0d0a 100644 --- a/server/channelserver/session.go +++ b/server/channelserver/session.go @@ -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),