private void sendMatchingFightCallBack(MatchMakingCouple mc) { ArrayList<Referee> refs = MARSP2PMatchMakingSystem.refereesStorage.giveMeNRefs(StaticDefinitions.NB_ARB_MINI); ArrayList<Node> refsN = null; if (refs != null) { refsN = new ArrayList<Node>(StaticDefinitions.NB_ARB_MINI); for (int i = 0; i < StaticDefinitions.NB_ARB_MINI; i++) { refsN.add(refs.get(i).getNode()); } } else { sendMatchingTestCallBack(mc); return; } if (StaticDefinitions.canIPrint("STD")) { System.out.println("Matched " + mc.getNode1() + " with " + mc.getNode2()); if (refsN != null) System.out.println(Arrays.toString(refsN.toArray())); } // message one, will be the initiator MatchMakingMessage m = new MatchMakingMessage(StaticDefinitions.MM_REPLY_FIGHT); m.referees = refsN; m.messageContent = new Duo<Integer, String>(0, mc.getNode2()); String ip = mc.getNode1().split(":")[0]; int port = Integer.parseInt(mc.getNode1().split(":")[1]); NetWorkSender.send(ip, port, m); // message two, will be the slave node m = new MatchMakingMessage(StaticDefinitions.MM_REPLY_FIGHT); m.referees = refsN; m.messageContent = new Duo<Integer, String>(1, mc.getNode1()); ip = mc.getNode2().split(":")[0]; port = Integer.parseInt(mc.getNode2().split(":")[1]); NetWorkSender.send(ip, port, m); if (StaticDefinitions.canIPrint("FEWER")) { System.out.println( "i matched : " + (port - 6666) + " with " + (Integer.parseInt(mc.getNode1().split(":")[1]) - 6666)); } }
private void sendMatchingTestCallBack(MatchMakingCouple mc) { // message one, will be the initiator MatchMakingMessage m = new MatchMakingMessage(StaticDefinitions.MM_REPLY_TEST); m.messageContent = new Duo<Integer, String>(0, mc.getNode2()); String ip = mc.getNode1().split(":")[0]; int port = Integer.parseInt(mc.getNode1().split(":")[1]); NetWorkSender.send(ip, port, m); // message two, will be the slave node m = new MatchMakingMessage(StaticDefinitions.MM_REPLY_TEST); m.messageContent = new Duo<Integer, String>(1, mc.getNode1()); ip = mc.getNode2().split(":")[0]; port = Integer.parseInt(mc.getNode2().split(":")[1]); NetWorkSender.send(ip, port, m); if (StaticDefinitions.canIPrint("FEWER")) { System.out.println( "i matched : " + (port - 6666) + " with " + (Integer.parseInt(mc.getNode1().split(":")[1]) - 6666)); } }