diff options
Diffstat (limited to 'NET/worlds/network/netProperty.java')
| -rw-r--r-- | NET/worlds/network/netProperty.java | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/NET/worlds/network/netProperty.java b/NET/worlds/network/netProperty.java new file mode 100644 index 0000000..c2f8e4b --- /dev/null +++ b/NET/worlds/network/netProperty.java @@ -0,0 +1,50 @@ +package NET.worlds.network; + +import java.io.IOException; + +public class netProperty { + protected int _propID; + protected String _value; + + public netProperty() { + this._propID = 0; + } + + public netProperty(int p) { + this._propID = p; + } + + public netProperty(int p, String val) { + assert val != null; + + this._propID = p; + this._value = val; + } + + public int property() { + return this._propID; + } + + public String value() { + return this._value; + } + + int packetSize() { + return this._value != null ? 2 + ServerOutputStream.utfLength(this._value) : 0; + } + + void parseNetData(ServerInputStream data) throws IOException { + this._propID = data.readUnsignedByte(); + this._value = data.readUTF(); + } + + void send(ServerOutputStream o) throws IOException { + o.writeByte(this._propID); + o.writeUTF(this._value); + } + + @Override + public String toString() { + return netCmds.getPropName(this._propID) + "=" + this._value; + } +} |