Skip to content

Commit

Permalink
Merge pull request #59 from juleskreutzer/RMI-implementation
Browse files Browse the repository at this point in the history
Rmi implementation
  • Loading branch information
juleskreutzer committed Dec 15, 2015
2 parents 5a6af01 + bc14655 commit 4486613
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ public void run() {
});

//System.setProperty("java.rmi.server.hostname","localhost");
Registry registry = LocateRegistry.getRegistry("127.0.0.1",7611);
//Registry registry = LocateRegistry.getRegistry("127.0.0.1",7611);
//Registry registry = LocateRegistry.getRegistry("10.0.1.41", 7611);
//Registry registry = LocateRegistry.getRegistry("145.93.56.144", 7611);
//Registry registry = LocateRegistry.getRegistry("145.93.106.162", 7611);
Registry registry = LocateRegistry.getRegistry("145.93.104.222", 7611);
connect = (IServerConnect)registry.lookup("HackAttackServerConnect");
} catch (NotBoundException | RemoteException ex) {
Logger.getLogger(FXMLLobbyController.class.getName()).log(Level.SEVERE, null, ex);
Expand Down
59 changes: 28 additions & 31 deletions Hack Attack Client/src/hack/attack/client/GraphicsEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,14 @@ public void spawn(Object object, int uID) throws DuplicateSpawnException, Invali
int currentID = ClientAdapter.getInstance().getCurrentUserID();
FXMLDocumentController.Window window = uID == currentID ? FXMLDocumentController.Window.DOWN : FXMLDocumentController.Window.TOP;

List<Node> list = parent.getAllNodes(window);
for(Node node : list){
if(node instanceof ObjectImage){
ObjectImage image = (ObjectImage)node;
if(image.getReference() == object){
throw new DuplicateSpawnException("This object already spawned!");
synchronized(this){
List<Node> list = parent.getAllNodes(window);
for(Node node : list){
if(node instanceof ObjectImage){
ObjectImage image = (ObjectImage)node;
if(image.getReference() == object){
throw new DuplicateSpawnException("This object already spawned!");
}
}
}
}
Expand Down Expand Up @@ -209,36 +211,31 @@ public void deSpawn(Object object, int uID) throws InvalidObjectException{
FXMLDocumentController.Window window = uID == currentID ? FXMLDocumentController.Window.DOWN : FXMLDocumentController.Window.TOP;

ArrayList<Node> nodes = this.getAllNodes();

for(Node n : nodes)
{
if(object instanceof Minion && n instanceof MinionImage)
synchronized(this){
for(Node n : nodes)
{
FXMLDocumentController.Window w = uID == currentID? FXMLDocumentController.Window.TOP : FXMLDocumentController.Window.DOWN;
Minion minion = (Minion)object;
Minion m = ((MinionImage)n).getMinion();
Rectangle hb = ((MinionImage)n).getHealthBar();
if(minion.getMinionID() == m.getMinionID()){
if(m.reachedBase()){
drawEffect(Effect.REACHED_BASE, m, w);
}else{
drawEffect(Effect.DIE, m, w);
if(object instanceof Minion && n instanceof MinionImage)
{
FXMLDocumentController.Window w = uID == currentID? FXMLDocumentController.Window.TOP : FXMLDocumentController.Window.DOWN;
Minion minion = (Minion)object;
Minion m = ((MinionImage)n).getMinion();
Rectangle hb = ((MinionImage)n).getHealthBar();
if(minion.getMinionID() == m.getMinionID()){
if(m.reachedBase()){
drawEffect(Effect.REACHED_BASE, m, w);
}else{
drawEffect(Effect.DIE, m, w);
}
parent.removeNode(hb, w);
parent.removeNode(n, w);
break;
}
parent.removeNode(hb, w);
parent.removeNode(n, w);
}
if(n instanceof SpawnTargetImage){
parent.removeNode(n, window);
break;
}
}
// if(n instanceof ObjectImage){
// ObjectImage image = (ObjectImage)n;
// if(object == image.getReference()){
// parent.removeNode(n, window);
// }
// }
if(n instanceof SpawnTargetImage){
parent.removeNode(n, window);
break;
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion Hack Attack Server/serverLog.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2015/12/14 17:30:47 - STATUS : OK - 5 : 3 : 3 : 4 : 0 : 0
2015/12/15 10:21:46 - STATUS : WARNING - Duration of spell is smaller then 0
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public static void main(String[] args) {
//System.setProperty( "java.rmi.server.hostname", "192.168.2.6" ) ;
//System.setProperty("java.rmi.server.hostname", "10.0.1.41");
//System.setProperty("java.rmi.server.hostname", "145.93.56.144");
System.setProperty("java.rmi.server.hostname", "145.93.240.143");
System.setProperty("java.rmi.server.hostname", "145.93.104.222");
Registry registry = LocateRegistry.createRegistry(7611);
registry.rebind("HackAttackServerConnect", connect);

Expand All @@ -85,7 +85,8 @@ public void update(double value) {
}

public static void writeConsole(Log log){
console.appendText(log.toString());

javafx.application.Platform.runLater( () -> console.appendText(log.toString()) );
}

}

0 comments on commit 4486613

Please sign in to comment.