Package marauroa.common.net.message
Class TransferContent
java.lang.Object
marauroa.common.net.message.TransferContent
A helper class to transfer content from server to client.
- Author:
- miguel, hendrik
-
Field Summary
Modifier and TypeFieldDescriptionboolean
If the client approved this content to be transfered it will be true.boolean
If the client can cache this content, this would be true.byte[]
The content itself.Name of the content to transfer.int
When this content was created or any other way of stamping the content for version control. -
Constructor Summary
ConstructorDescriptionConstructorTransferContent(String name, int timestamp, byte[] data)
Constructor -
Method Summary
Modifier and TypeMethodDescriptionbyte[]
getHash()
gets the hashbyte[]
gets the transmitted hash, may benull
.void
readACK(InputSerializer in)
Reads the content acceptance from clientvoid
readACKFromMap(String contentName, Object accept)
Reads the content acceptance from clientvoid
readFULL(InputSerializer in)
Read the content data from server.void
readREQ(InputSerializer in)
Reads the content transfer request.toString()
void
writeACK(OutputSerializer out)
Write a content acceptance to server.void
writeACKToJson(StringBuilder out)
writes an ACK to JSONvoid
writeFULL(OutputSerializer out)
Write the content data to clientvoid
writeFullToJson(StringBuilder out)
Write the content data to the servervoid
writeREQ(OutputSerializer out)
Write content as a request to client to approve itvoid
writeREQToJson(StringBuilder out)
Write content as a request to client to approve it
-
Field Details
-
name
Name of the content to transfer. Usually it is a file name. -
timestamp
public int timestampWhen this content was created or any other way of stamping the content for version control. -
data
public byte[] dataThe content itself. -
cacheable
public boolean cacheableIf the client can cache this content, this would be true. -
ack
public boolean ackIf the client approved this content to be transfered it will be true.
-
-
Constructor Details
-
TransferContent
public TransferContent()Constructor -
TransferContent
Constructor- Parameters:
name
- name of the contenttimestamp
- version control timestamp.data
- data of the content.
-
-
Method Details
-
getHash
public byte[] getHash()gets the hash- Returns:
- hash
-
getTransmittedHash
public byte[] getTransmittedHash()gets the transmitted hash, may benull
.- Returns:
- transmitted hash or
null
-
toString
-
writeREQ
Write content as a request to client to approve it- Parameters:
out
-- Throws:
IOException
-
writeREQToJson
Write content as a request to client to approve it- Parameters:
out
-
-
readREQ
Reads the content transfer request.- Parameters:
in
-- Throws:
IOException
-
writeACK
Write a content acceptance to server.- Parameters:
out
-- Throws:
IOException
-
writeACKToJson
writes an ACK to JSON- Parameters:
out
- StringBuilder
-
readACK
Reads the content acceptance from client- Parameters:
in
-- Throws:
IOException
-
readACKFromMap
Reads the content acceptance from client- Parameters:
contentName
- name of contentaccept
- does the client what this content?
-
writeFULL
Write the content data to client- Parameters:
out
-- Throws:
IOException
-
writeFullToJson
Write the content data to the server- Parameters:
out
- output
-
readFULL
Read the content data from server.- Parameters:
in
-- Throws:
IOException
-