Class games.Battle.shared.comm.BattlePacket
All Packages Class Hierarchy This Package Previous Next Index
Class games.Battle.shared.comm.BattlePacket
java.lang.Object
|
+----games.Battle.shared.comm.BattlePacket
- public class BattlePacket
- extends Object
An abstract base class for all battle communication data packets.
Classes derived from BattlePacket encapsulate some sort of
object that needs to be transmitted between the server game
engine and the client game player, in either direction.
Derived classes implement the methods toBytes() and fromBytes()
to convert themselves to and from a stream of bytes. BattlePacket
implements the writeTo() and readFrom() methods to provide transmission
of the data to and from an Input/OutputStream
-
BattlePacket()
-
-
fromBytes(byte[])
- Converts the given array of bytes into a particular
BattlePacket.
-
readFrom(InputStream)
- Reads data from the given input stream and builds a
particular BattlePacket from that data.
-
toBytes()
- Converts this BattlePacket to an array of bytes for
transmission.
-
writeTo(OutputStream)
- Writes this BattlePacket to the given output stream
BattlePacket
public BattlePacket()
toBytes
protected abstract byte[] toBytes()
- Converts this BattlePacket to an array of bytes for
transmission.
fromBytes
protected abstract void fromBytes(byte data[])
- Converts the given array of bytes into a particular
BattlePacket.
- Parameters:
- data - the array of data to be converted
readFrom
public int readFrom(InputStream is) throws IOException
- Reads data from the given input stream and builds a
particular BattlePacket from that data.
- Parameters:
- is - the input stream from which the data is pulled
writeTo
public void writeTo(OutputStream os) throws IOException
- Writes this BattlePacket to the given output stream
- Parameters:
- os - the output stream on which to write the data
All Packages Class Hierarchy This Package Previous Next Index