Up Previous Next

Here are the changes in the client's class:

import java.awt.*; 
import javax.swing.*; 

import java.rmi.*; 
import java.rmi.server.*; 

public class Client extends JFrame implements ClientInterface { 

  public Client() {
    this.setTitle("iceblox: client frame"); 
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
    this.setSize(300, 200); 
    this.setVisible(true); 
  }   

  ServerInterface server; 

  public void registerWith(ServerInterface server) throws RemoteException {
    this.server = server; 
    this.id = server.register(this);     
    System.out.println("I have registered, I have id: " + this.id); 
  } 

  int id = -1; 

  public static void main(String[] args) {
    try {
        ServerInterface far = 
            (ServerInterface)Naming.lookup("rmi://" +  // protocol 
                                            args[0] +  // host machine 
                                           ":" + 
                                            args[1] +  // port on the host 
                                           "/Dirac");  // name server bound as         
        
        Client here = new Client(); 
                
        UnicastRemoteObject.exportObject(here); 
        
        here.register(far); 
            
        } catch (Exception e) {
            System.out.println("Error in client..." + e); 
            e.printStackTrace();
        }  
  } 
}
And now we're essentially done.
Up Previous Next