Package networking.request

Source Code of networking.request.RequestHeartbeat

package networking.request;

import java.io.IOException;

import model.World;
import networking.response.GameResponse;

import worldManager.gameEngine.GameEngine;

/**
*
* @author Xuyuan
*/
public class RequestHeartbeat extends GameRequest {

    public RequestHeartbeat() {
    }

    @Override
    public void parse() throws IOException {
        //Do nothing here.
    }

    @Override
    public void doBusiness() throws Exception {
        for (GameResponse response : client.getUpdates()) {
            try {
                client.getOutputStream().write(response.constructResponseInBytes());
            } catch (IOException ex) {
                System.err.println(ex.getMessage());
            }
        }

        World world = client.getWorld();

        if (world != null) {
            GameEngine gameEngine = world.getGameEngine();
            if (gameEngine != null) {
                gameEngine.run();
            }
        }
    }
}
TOP

Related Classes of networking.request.RequestHeartbeat

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.