Bonjour à tous,
je vais essayer d'expliquer mon code:
J'ai un JPanel qui tourne en boucle et appel start.Display(Graphics2D g){ save.server(1099); }
Ensuite j'ai ça:
ServerRemote "implements" Remote et Game c'est l'objet distant.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14 public class ServerUnicastRemote extends UnicastRemoteObject implements ServerRemote{ Game game; public ServerUnicastRemote(Game game) throws RemoteException { super(); this.game = game; } public Game getGame() { return game; } public void setGame(Game game) { this.game = game; } @Override public void Display() throws RemoteException { game.Display(); } }
Dans Save j'ai ça, mais c'est pas le problème, ce code là fonctionne:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11 public class Game{ Graphics2D g; public Game(){} public Game setG2D(Graphics2D g){ this.g = g; return this; } public void Display() { g.drawRect(10, 10, 10, 10); } }
et dans
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 public void server(int port) { try { LocateRegistry.createRegistry(port); ServerUnicastRemote od = new ServerUnicastRemote(game); String url = "rmi://" + InetAddress.getLocalHost().getHostAddress() + "/SSJEngine"; System.out.println("Enregistrement de l'objet avec l'url : " + url); Naming.rebind(url, od); } catch (Exception e){e.printStackTrace();} } public ServerRemote client(String ip) { try { ServerRemote stub = (ServerRemote) Naming.lookup("rmi://" + ip + "/SSJEngine"); return stub; } catch (Exception e) {e.printStackTrace();} return null; }
Evidemment ça ne marche pas mais vous avez surement compris l'idée,
Alors ma question est, "Pourquoi ça ne marche pas?" et "Comment je doit faire?"
Merci de votre aide.







Répondre avec citation
Partager