hosting a game now continues to send out the info of the race

#story[1188]
This commit is contained in:
hba56
2017-08-31 15:06:43 +12:00
parent a1fa09962a
commit d1c0797db7
7 changed files with 61 additions and 10 deletions
@@ -0,0 +1,41 @@
package visualiser.network;
import network.Exceptions.InvalidMessageException;
import network.Messages.AC35Data;
import network.Messages.HostGame;
import shared.model.RunnableWithFramePeriod;
import java.io.IOException;
import java.net.DatagramSocket;
public class MatchBrowserHostRunnable implements RunnableWithFramePeriod {
private MatchBrowserInterface matchBrowserInterface;
private DatagramSocket socket;
private AC35Data gameInfo;
public MatchBrowserHostRunnable(MatchBrowserInterface matchBrowserInterface, DatagramSocket socket, AC35Data gameInfo) {
this.matchBrowserInterface = matchBrowserInterface;
this.socket = socket;
this.gameInfo = gameInfo;
}
@Override
public void run(){
long previousFrameTime = System.currentTimeMillis();
while (!Thread.interrupted()) {
long currentFrameTime = System.currentTimeMillis();
waitForFramePeriod(previousFrameTime, currentFrameTime, 10000);
previousFrameTime = currentFrameTime;
try{
matchBrowserInterface.sendOutGameInfo(gameInfo, socket);
}catch (IOException e){
System.err.println("HostGameMessage could not be sent");
}
}
}
}