Example #1
0
func (m *TurnMessage) ReadPacket(_packet pnet.IPacket) error {
	direction, err := _packet.ReadUint16()
	if err != nil {
		return err
	}
	m.Direction = direction

	return nil
}
Example #2
0
// 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
}
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
	}
}
Example #4
0
// 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
}