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
FieldsModifier and TypeFieldDescriptionbooleanIf the client approved this content to be transfered it will be true.booleanIf the client can cache this content, this would be true.byte[]The content itself.Name of the content to transfer.intWhen this content was created or any other way of stamping the content for version control. -
Constructor Summary
ConstructorsConstructorDescriptionConstructorTransferContent(String name, int timestamp, byte[] data)Constructor -
Method Summary
Modifier and TypeMethodDescriptionbyte[]getHash()gets the hashbyte[]gets the transmitted hash, may benull.voidreadACK(InputSerializer in)Reads the content acceptance from clientvoidreadACKFromMap(String contentName, Object accept)Reads the content acceptance from clientvoidreadFULL(InputSerializer in)Read the content data from server.voidreadREQ(InputSerializer in)Reads the content transfer request.toString()voidwriteACK(OutputSerializer out)Write a content acceptance to server.voidwriteACKToJson(StringBuilder out)writes an ACK to JSONvoidwriteFULL(OutputSerializer out)Write the content data to clientvoidwriteFullToJson(StringBuilder out)Write the content data to the servervoidwriteREQ(OutputSerializer out)Write content as a request to client to approve itvoidwriteREQToJson(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
-