public TouchEvent DecodeTouch(UnPacker unpacker) { int length = unpacker.UnpackByte(); Touch[] touches = new Touch[length]; for (int i = 0; i < length; i++) { Touch touch; touch.Location.X = unpacker.UnpackShort(); touch.Location.Y = unpacker.UnpackShort(); touch.Pressure = unpacker.UnpackByte() / 256.0f; touches[i] = touch; } return new TouchEvent(touches); }
private int UnpackID(UnPacker unpacker) { if (this.nextID < sbyte.MaxValue) { return unpacker.UnpackByte(); } else if (this.nextID < short.MaxValue) { return unpacker.UnpackShort(); } else { return unpacker.UnpackInteger(); } }
protected override byte[] processMessage(UnPacker unPacker) { unPacker.UnpackByte(); //Remove id byte from message. return unPacker.UnpackByteArray(unPacker.remaining()); }
protected override byte[] processMessage(UnPacker unPacker) { int flags = unPacker.UnpackByte(); int accnum = unPacker.UnpackInteger(); if ((flags & ACK_BIT) == ACK_BIT) { connection.reliableTimer.removeResender(accnum); return null; } else { sendAckMessage(accnum); return processRecivedMessage(unPacker, accnum); } }
protected override byte[] processMessage(UnPacker unPacker) { unPacker.UnpackByte(); int seqNum = unPacker.UnpackInteger(); if (seqNum < lastRecivedSequenceNumber) { return null; //Discard the message if it is old. } else { lastRecivedSequenceNumber = seqNum; return unPacker.UnpackByteArray(unPacker.remaining()); } }