"Michael Oschmann" <[EMAIL PROTECTED]> writes:

>    Hi Loic,
>
>
>    With PacketpokerChat, am I correct in saying that the following, is
>    the manner in which to unpack:
>
>
>
>    public override function unpack(b:ByteArray = null):ByteArray
>
>    {
>
>          this.serial = b.readUnsignedInt();
>
>    this.gameId = b.readUnsignedInt();
>
>          this.messageSize = b.readShort();
>
>          this.message = b.readUTFBytes(this.messageSize);
>
>
>          return b;
>
>    }
>
>
>
>    ?????
>
>
>    As far as I can understand, you don't need the reading of the serial
>    as this packet is sent to all players?

     Here is the function I sent you in a previous mail. The serial
is the serial of the player chatting. You need to unpack it.

// code for POKER_CHAT (('serial', 0, 'I'), ('cookie', '', 'no net'), 
('game_id', 0, 'I'), ('message', '', 's'))
public class PacketPokerChat extends Packet
{
        public var serial:int;
        public var game_id:int;
        public var message:String;

        public override function unpack(bytes:ByteArray):ByteArray
        {
                bytes = super.unpack(bytes);
                this.serial = bytes.readUnsignedInt();
                this.game_id = bytes.readUnsignedInt();
                {
                        var size:int = bytes.readUnsignedShort();
                        this.message = bytes.readUTFBytes(size);
                }
                return bytes;
        }

        public override function pack():ByteArray
        {
                var bytes:ByteArray = super.pack();
                bytes.writeUnsignedInt(this.serial);
                bytes.writeUnsignedInt(this.game_id);
                bytes.writeUnsignedShort(this.message.length);
                bytes.writeUTFBytes(this.message, this.message.length)
                return bytes;
        }

        public override function calcsize():int
        {
                var size:int = super.calcsize();
                size += 4; // serial
                size += 4; // game_id
                size += 2 + this.message.length;
                return size;
        }
}

-- 
+33 1 76 60 72 81  Loic Dachary mailto:[EMAIL PROTECTED]
http://dachary.org/loic/gpg.txt sip:[EMAIL PROTECTED]
Latitude: 48.86962325498033 Longitude: 2.3623046278953552

_______________________________________________
Pokersource-users mailing list
[email protected]
https://mail.gna.org/listinfo/pokersource-users

Reply via email to