mirror of
https://github.com/Mezeporta/Erupe.git
synced 2025-12-15 08:25:09 +01:00
Stage object notification test
This commit is contained in:
@@ -6,7 +6,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// MsgSysInsertUser represents the MSG_SYS_INSERT_USER
|
// MsgSysInsertUser represents the MSG_SYS_INSERT_USER
|
||||||
type MsgSysInsertUser struct{}
|
type MsgSysInsertUser struct {
|
||||||
|
CharID uint32
|
||||||
|
}
|
||||||
|
|
||||||
// Opcode returns the ID associated with this packet type.
|
// Opcode returns the ID associated with this packet type.
|
||||||
func (m *MsgSysInsertUser) Opcode() network.PacketID {
|
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.
|
// Build builds a binary packet from the current data.
|
||||||
func (m *MsgSysInsertUser) Build(bf *byteframe.ByteFrame) error {
|
func (m *MsgSysInsertUser) Build(bf *byteframe.ByteFrame) error {
|
||||||
panic("Not implemented")
|
bf.WriteUint32(m.CharID)
|
||||||
}
|
return nil
|
||||||
|
}
|
||||||
|
|||||||
@@ -6,7 +6,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// MsgSysNotifyUserBinary represents the MSG_SYS_NOTIFY_USER_BINARY
|
// 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.
|
// Opcode returns the ID associated with this packet type.
|
||||||
func (m *MsgSysNotifyUserBinary) Opcode() network.PacketID {
|
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.
|
// Build builds a binary packet from the current data.
|
||||||
func (m *MsgSysNotifyUserBinary) Build(bf *byteframe.ByteFrame) error {
|
func (m *MsgSysNotifyUserBinary) Build(bf *byteframe.ByteFrame) error {
|
||||||
panic("Not implemented")
|
bf.WriteUint32(m.CharID)
|
||||||
}
|
bf.WriteUint8(m.BinaryType)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|||||||
@@ -301,8 +301,35 @@ func handleMsgSysEnterStage(s *Session, p mhfpacket.MHFPacket) {
|
|||||||
s.QueueAck(pkt.AckHandle, []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})
|
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 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) {}
|
func handleMsgSysBackStage(s *Session, p mhfpacket.MHFPacket) {}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ type Session struct {
|
|||||||
// NewSession creates a new Session type.
|
// NewSession creates a new Session type.
|
||||||
func NewSession(server *Server, conn net.Conn) *Session {
|
func NewSession(server *Server, conn net.Conn) *Session {
|
||||||
s := &Session{
|
s := &Session{
|
||||||
logger: server.logger,
|
logger: server.logger.Named(conn.RemoteAddr().String()),
|
||||||
server: server,
|
server: server,
|
||||||
rawConn: conn,
|
rawConn: conn,
|
||||||
cryptConn: network.NewCryptConn(conn),
|
cryptConn: network.NewCryptConn(conn),
|
||||||
|
|||||||
Reference in New Issue
Block a user