Package client
Class Packet
java.lang.Object
client.Packet
The Packet class holds the Packet object which is used commonly within the Client in order to send and recieve data.
It can be converted to and from a JadeObject in order to provide ease of use when trying to send structured data.
- Since:
- 2023
-
Constructor Summary
ConstructorDescriptionPacket()
Null packet constructorConstructor of a packet with no checkSum.checkSum is initialized to 1.Constructor of a full packet. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Returns true if the packet has a valid checkSum for its contents.Returns the check sum of this.getData()
Returns the data of this.Returns the reciever of this.Returns the sender of this.getType()
Returns the type of this.void
setCheckSum
(String checkSum) Sets the check sum of this.void
Sets the data of this.void
setReciever
(String reciever) Sets the reciever of this.void
Sets the sender of this.void
Sets the type of this.String[]
toArray()
Converts the packet into a string array.Converts a Packet object to a JadeObject.This is done by creating a JadePair for each variable of the packet.toString()
Converts the packet to a string, this is an unstructured string.
-
Constructor Details
-
Packet
public Packet()Null packet constructor -
Packet
Constructor of a packet with no checkSum.checkSum is initialized to 1.- Parameters:
sender
- this clientreciever
- intended recipienttype
- type of data being sentdata
- the data being sent
-
Packet
Constructor of a full packet.- Parameters:
sender
- this clientreciever
- intended recipienttype
- type of data being sentdata
- the data being sentcheckSum
- check sum of the data
-
-
Method Details
-
checkPacket
public boolean checkPacket()Returns true if the packet has a valid checkSum for its contents. TODO: implement fully- Returns:
- boolean
-
toArray
Converts the packet into a string array.- Returns:
- String array
-
toJadeObject
Converts a Packet object to a JadeObject.This is done by creating a JadePair for each variable of the packet. The JadePairs are then used to create a JadeObject which is then returned. If the data of the packet is null a PacketConversionException is thrown.- Returns:
- JadeObject
-
toString
Converts the packet to a string, this is an unstructured string. -
getSender
Returns the sender of this.- Returns:
- String
-
setSender
Sets the sender of this.- Parameters:
sender
- sender
-
getReciever
Returns the reciever of this.- Returns:
- String
-
setReciever
Sets the reciever of this.- Parameters:
reciever
- reciever
-
getType
Returns the type of this.- Returns:
- String
-
setType
Sets the type of this.- Parameters:
type
- type
-
getData
Returns the data of this.- Returns:
- String
-
setData
Sets the data of this.- Parameters:
data
- data
-
getCheckSum
Returns the check sum of this.- Returns:
- String
-
setCheckSum
Sets the check sum of this.- Parameters:
checkSum
- check sum
-