This commit is contained in:
Lorenzo Iovino 2017-07-07 15:50:00 +02:00
parent e5c3202bb2
commit 3a528f307b
25 changed files with 1138 additions and 473 deletions

View file

@ -15,7 +15,6 @@ public class HomeController {
public Response login(String userName, String password) throws RemoteException, NotBoundException, MalformedURLException {
Response res = App.authService.login(userName,password);
System.out.println(res.data);
if (res.code == 200){
App.session = (new Session(new User(userName,password,0), res.data.get("token").toString()));
}

View file

@ -91,7 +91,6 @@ public class Game {
//Invia tcp req a server per dirgli che sto joinando
DefaultListModel<String> matchNames = new DefaultListModel<String>();
matchNames.addElement(matchName);
System.out.println("STO JOINANDO");
Message message = new Message("JOIN_GAME", App.session.account.userName, App.session.token, matchNames);
byte[] byteMessage = new String(message.toString()).getBytes();

View file

@ -29,7 +29,6 @@ public class FetchHighscore extends SwingWorker<Void,Void> {
public Void doInBackground() {
Message message = new Message("FETCH_HIGHSCORES", App.session.account.userName, App.session.token, new DefaultListModel<>());
buffer = ByteBuffer.allocate(1024);
System.out.println("SENDDDDD MESSAGE");
byte[] byteMessage = message.toString().getBytes();
buffer = ByteBuffer.wrap(byteMessage);
try {
@ -49,7 +48,6 @@ public class FetchHighscore extends SwingWorker<Void,Void> {
if (line.startsWith("MESSAGE")) {
Message msg = Message.toMessage(line);
System.out.println(line);
if (msg.message.equals("HIGHSCORES") && msg.data != null) {
for(int i = 0; i< msg.data.size()-1; i++){
@ -69,10 +67,8 @@ public class FetchHighscore extends SwingWorker<Void,Void> {
}
public void done(){
System.out.println("Done Highscores");
App.game.globalRanks = globalRanks;
this.highscoresPage.showHighscoreList();
System.out.println("DODODO");
}
}

View file

@ -82,7 +82,6 @@ public class InvitePlayers extends SwingWorker<Boolean,Void> {
@Override
public void done() {
System.out.println("Done invite players");
}
}

View file

@ -52,7 +52,6 @@ public class SendWords extends SwingWorker<Void,Void> {
Message msg = new Message("WORDS", App.session.account.userName, "", words);
String sentence = msg.toString();
sendData = sentence.getBytes();
System.out.println("SENDIJIIDIIDIDIDIDDIDIDIDIDI");
DatagramPacket sendPacket = new DatagramPacket(sendData, sendData.length, IPAddress, Config.WordsReceiverServerPort);
clientSocket.send(sendPacket);
clientSocket.close();*/
@ -70,7 +69,6 @@ public class SendWords extends SwingWorker<Void,Void> {
@Override
public void done(){
System.out.println("Done send SCOREEEEEE");
try {
this.callback.execute();
} catch (Exception e) {

View file

@ -30,7 +30,6 @@ public class StartGame extends SwingWorker<Void,Void> {
@Override
public Object call() throws Exception {
gamePage.showLetters();
System.out.println(letters);
gamePage.timer.start();
return null;
}
@ -40,6 +39,5 @@ public class StartGame extends SwingWorker<Void,Void> {
@Override
public void done(){
System.out.println("Done start gamePage");
}
}

View file

@ -70,7 +70,7 @@ public class WaitForPlayers extends SwingWorker<DefaultListModel<String>,Default
new Callable() {
@Override
public Object call() throws Exception {
socketChannel.close();
//socketChannel.close();
return new MenuPage(Page.window);
}
@ -85,13 +85,10 @@ public class WaitForPlayers extends SwingWorker<DefaultListModel<String>,Default
if(msg.data !=null ) {
data= msg.data;
System.out.println("HERE");
Integer multicastId = Integer.valueOf(data.remove(data.size()-2));
System.out.println(multicastId);
App.game.setMulticastId(multicastId);
App.game.multicastSocket = new MulticastSocket(App.game.multicastId);
System.out.println(App.game.multicastSocket);
InetAddress ia = InetAddress.getByName(Config.ScoreMulticastServerURI);
App.game.multicastSocket.joinGroup(ia);
letters = msg.data;
@ -105,7 +102,6 @@ public class WaitForPlayers extends SwingWorker<DefaultListModel<String>,Default
}
}
} catch (IOException e) {
System.out.println("ECCEZIONE, GIOCO NON ESISTE. ELIMINALO");
e.printStackTrace();
}
@ -115,17 +111,13 @@ public class WaitForPlayers extends SwingWorker<DefaultListModel<String>,Default
@Override
public void done(){
if(!joinTimeout) {
System.out.println("Done wait for players");
try {
System.out.println(letters);
App.game.setLetters(letters);
System.out.println("PAROLE IN INVIO");
this.callback.execute();
} catch (Exception e) {
e.printStackTrace();
}
} else {
System.out.println("TIMEOUT HAPPEN, GO TO MENU PAGE");
}
}
}

View file

@ -34,14 +34,10 @@ public class WaitForScore extends SwingWorker<Void,Void> {
Message msg;
while(true) {
byte[] buf = new byte[1024];
System.out.println("SONO QUIIIII");
DatagramPacket recv = new DatagramPacket(buf, buf.length);
System.out.println("ANCORA QUII");
App.game.multicastSocket.receive(recv);
String s = new String(recv.getData());
System.out.println("HSHSHSHS");
System.out.println(s);
msg = Message.toMessage(s);
if(msg.message.equals("FINALSCORE")){
break;
@ -51,20 +47,13 @@ public class WaitForScore extends SwingWorker<Void,Void> {
if(msg.data != null) {
for (int i = 0; i < msg.data.size() - 1; i++) {
String[] splitted = msg.data.get(i).split(":");
System.out.println(splitted.toString());
ranks.addElement(new Pair<String, Integer>(splitted[0], new Integer(splitted[1])));
}
}
App.game.ranks = ranks;
App.game.multicastSocket.leaveGroup(InetAddress.getByName(Config.ScoreMulticastServerURI));
System.out.println(App.game.ranks);
System.out.println("ENDDDDd");
App.game.multicastSocket.disconnect();
App.game.multicastSocket.close();
} catch (UnknownHostException e) {
e.printStackTrace();
} catch (IOException e) {
@ -75,10 +64,7 @@ public class WaitForScore extends SwingWorker<Void,Void> {
@Override
public void done(){
System.out.println("Done ranks");
App.game.ranks = ranks;
// App.game.multicastSocket.close();
//App.game.clientSocket.close();
try {
this.callback.execute();