UploadSession.vala 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. using Invercargill;
  2. namespace Pprf.Messages {
  3. public class UploadSession : Message {
  4. public uint8[] session_authentication { get; set; }
  5. public uint32 max_chunk_size { get; set; }
  6. public UploadSession() {
  7. message_type = MessageType.UPLOAD_SESSION;
  8. }
  9. public override void deserialise (GLib.DataInputStream stream) throws Error {
  10. base.deserialise (stream);
  11. var auth_size = stream.read_uint16();
  12. session_authentication = new uint8[auth_size];
  13. stream.read(session_authentication);
  14. max_chunk_size = stream.read_uint32();
  15. }
  16. public override uint64 calculate_size() {
  17. return base.calculate_size() +
  18. 2 + // Auth size field
  19. session_authentication.length +
  20. 4; // Chunk size field
  21. }
  22. public override void serialise(DataOutputStream stream) throws Error {
  23. base.serialise(stream);
  24. stream.put_uint16((uint16)session_authentication.length);
  25. stream.write(session_authentication);
  26. stream.put_uint32(max_chunk_size);
  27. }
  28. }
  29. }