コード例 #1
0
ファイル: TurnMessage.go プロジェクト: toophy/go-gameserver
func (m *TurnMessage) ReadPacket(_packet pnet.IPacket) error {
	direction, err := _packet.ReadUint16()
	if err != nil {
		return err
	}
	m.Direction = direction

	return nil
}
コード例 #2
0
ファイル: WalkMessage.go プロジェクト: toophy/go-gameserver
// ReadPacket reads all data from a packet and puts it in the object
func (m *WalkMessage) ReadPacket(_packet pnet.IPacket) error {
	direction, err := _packet.ReadUint16()
	if err != nil {
		return err
	}
	m.Direction = direction

	sendMap, err := _packet.ReadUint16()
	if err != nil {
		return err
	}

	if sendMap == 1 {
		m.SendMap = true
	}

	return nil
}
コード例 #3
0
func (cw *ConnectionWrapper) processPacket(_packet pnet.IPacket) {
	header, err := _packet.ReadUint8()
	if err != nil {
		return
	}

	var netmessage pnet.INetMessageReader
	if header == pnet.HEADER_WALK {
		netmessage = netmsg.NewWalkMessage(nil)
		netmessage.ReadPacket(_packet)
	} else {
		log.Warning("ConnectionWrapper", "processPacket", "Received packet with unknown header: %d", header)
	}

	// Push netmessage on rxChan
	if netmessage != nil {
		cw.rxChan <- netmessage
	}
}
コード例 #4
0
ファイル: LoginMessage.go プロジェクト: toophy/go-gameserver
// ReadPacket reads all data from a packet and puts it in the object
func (m *LoginMessage) ReadPacket(_packet pnet.IPacket) error {
	var err error
	if m.Username, err = _packet.ReadString(); err != nil {
		return err
	}
	if m.Password, err = _packet.ReadString(); err != nil {
		return err
	}
	clientVersion, err := _packet.ReadUint16()
	if err != nil {
		return err
	}
	m.ClientVersion = int(clientVersion)

	return nil
}