|
|
|
@ -2,20 +2,18 @@ package visualiser.network;
|
|
|
|
|
|
|
|
|
|
|
|
import network.BinaryMessageEncoder;
|
|
|
|
import network.BinaryMessageEncoder;
|
|
|
|
import network.Exceptions.InvalidMessageException;
|
|
|
|
import network.Exceptions.InvalidMessageException;
|
|
|
|
import network.MessageDecoders.HostedGamesRequestDecoder;
|
|
|
|
|
|
|
|
import network.MessageEncoders.HostGameMessageEncoder;
|
|
|
|
import network.MessageEncoders.HostGameMessageEncoder;
|
|
|
|
import network.MessageEncoders.HostedGamesRequestEncoder;
|
|
|
|
import network.MessageEncoders.HostedGamesRequestEncoder;
|
|
|
|
import network.Messages.AC35Data;
|
|
|
|
import network.Messages.AC35Data;
|
|
|
|
import network.Messages.Enums.MessageType;
|
|
|
|
import network.Messages.Enums.MessageType;
|
|
|
|
import network.Messages.HostGamesRequest;
|
|
|
|
import network.Messages.HostGamesRequest;
|
|
|
|
import shared.model.RunnableWithFramePeriod;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.net.*;
|
|
|
|
import java.net.DatagramPacket;
|
|
|
|
|
|
|
|
import java.net.DatagramSocket;
|
|
|
|
|
|
|
|
import java.net.InetAddress;
|
|
|
|
|
|
|
|
import java.net.UnknownHostException;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Enumeration;
|
|
|
|
|
|
|
|
import java.util.logging.Level;
|
|
|
|
|
|
|
|
import java.util.logging.Logger;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* UDP interface for the matchBrowser to send out hosted game info and get in other hosts info
|
|
|
|
* UDP interface for the matchBrowser to send out hosted game info and get in other hosts info
|
|
|
|
@ -40,6 +38,7 @@ public class MatchBrowserInterface {
|
|
|
|
* Used by host to send out race information to the server
|
|
|
|
* Used by host to send out race information to the server
|
|
|
|
* @param gameInfo the hostGame info for message
|
|
|
|
* @param gameInfo the hostGame info for message
|
|
|
|
* @param socket the udp socket assigned on startup
|
|
|
|
* @param socket the udp socket assigned on startup
|
|
|
|
|
|
|
|
* @throws IOException socket error
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
protected void sendOutGameInfo(AC35Data gameInfo, DatagramSocket socket) throws IOException{
|
|
|
|
protected void sendOutGameInfo(AC35Data gameInfo, DatagramSocket socket) throws IOException{
|
|
|
|
byte[] fullMessageToSend;
|
|
|
|
byte[] fullMessageToSend;
|
|
|
|
@ -59,6 +58,8 @@ public class MatchBrowserInterface {
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* start to send these messages on repeat until game stopped
|
|
|
|
* start to send these messages on repeat until game stopped
|
|
|
|
|
|
|
|
* @param gameInfo hostgame data
|
|
|
|
|
|
|
|
* @param socket socket to send to
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public void startSendingHostData(AC35Data gameInfo, DatagramSocket socket){
|
|
|
|
public void startSendingHostData(AC35Data gameInfo, DatagramSocket socket){
|
|
|
|
MatchBrowserHostRunnable hostRunnable = new MatchBrowserHostRunnable(this, socket, gameInfo);
|
|
|
|
MatchBrowserHostRunnable hostRunnable = new MatchBrowserHostRunnable(this, socket, gameInfo);
|
|
|
|
@ -69,6 +70,7 @@ public class MatchBrowserInterface {
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Used by a client to setup a connection with the match browser server
|
|
|
|
* Used by a client to setup a connection with the match browser server
|
|
|
|
* @return the socket created for this connection
|
|
|
|
* @return the socket created for this connection
|
|
|
|
|
|
|
|
* @throws IOException socket error
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public DatagramSocket setupMatchBrowserConnection() throws IOException{
|
|
|
|
public DatagramSocket setupMatchBrowserConnection() throws IOException{
|
|
|
|
DatagramSocket clientSocket = new DatagramSocket();
|
|
|
|
DatagramSocket clientSocket = new DatagramSocket();
|
|
|
|
|