// we need to register our custom packet first
NetworkConfig.registerPacket((short) 1, AllFieldTypePacket.class);
NetworkConfig.DEBUG = true;
try {
BaseClient bsClient = new TCPClient(host, port); // create client
// and connect
// to server
int sendCounter = 0;
System.out.println("Start the Client...");
// network loop
while (true) {
bsClient.update(100); // the main work
// send packet to server
// every 50 tick
if (++sendCounter % 50 == 0) {
bsClient.sendPacket(new AllFieldTypePacket());
}
// disconnect from server
// after 200 tick
if (sendCounter > 200) {
bsClient.silentDisconnect();
break;
}
try {
Thread.sleep(100);