Host also can be it's own client.

The host can connect to itself to become a client, packets are also sending from the host to client, update method should be ready to fully implemented. Added chatter packets to packet types to be used mostly for testing but can be further implemented for proper use in the future.

#story[1055]
This commit is contained in:
Kusal Ekanayake
2017-07-20 13:53:53 +12:00
parent 1e80d76acd
commit b1575e57df
10 changed files with 82 additions and 14 deletions
@@ -29,4 +29,5 @@ public class BoatActionMessage extends Message{
return MESSAGE_SIZE;
}
}
@@ -0,0 +1,38 @@
package seng302.server.messages;
/**
* Created by kre39 on 20/07/17.
*/
public class ChatterMessage extends Message {
private final long MESSAGE_VERSION_NUMBER = 1;
private final int MESSAGE_SIZE = 3;
private int message_type;
private int message_size = 21;
private String message;
public ChatterMessage(int message_type, int message_size, String message) {
this.message_type = message_type;
this.message_size = message_size;
this.message = message;
setHeader(new Header(MessageType.CHATTER_TEXT, 1, (short) getSize()));
allocateBuffer();
writeHeaderToBuffer();
putByte((byte) MESSAGE_VERSION_NUMBER);
putInt(message_type, 1);
putInt(message_size, 1);
putBytes(message.getBytes());
writeCRC();
rewind();
}
@Override
public int getSize() {
return MESSAGE_SIZE + message_size;
}
}
@@ -219,5 +219,4 @@ public abstract class Message {
data[right] = (byte) (temp & 0xff);
}
}
}