Skip to content
Snippets Groups Projects
Select Git revision
  • 08e608c6fcf745548c73677c5fdebd90bebc1860
  • master default protected
2 results

Fuzzer.java

Blame
  • Forked from Toby Murray / swen90006-a2-2020
    Source project has a limited visibility.
    Client1.java 1.70 KiB
    package client;
    
    import remote.IChatController;
    import remote.IClientController;
    
    import java.rmi.NotBoundException;
    import java.rmi.RemoteException;
    import java.rmi.registry.LocateRegistry;
    import java.rmi.registry.Registry;
    import java.util.concurrent.TimeUnit;
    
    public class Client1
    {
        private String userName;
        private Registry registryServer;
        private IChatController chatController;
        private IClientController clientController;
        private ChatUpdate chatUpdate;
    
        public Client1(String userName) throws RemoteException
        {
            this.userName = userName;
            this.chatUpdate = new ChatUpdate();
        }
    
        public static void main(String[] args)
        {
            try
            {
                Client1 client1 = new Client1("Hai");
                client1.run();
            }
            catch (Exception e)
            {
                e.printStackTrace();
            }
        }
    
        public void run() throws RemoteException, NotBoundException
        {
            connect();
    
            try
            {
                TimeUnit.MINUTES.sleep(5);
            }
            catch(Exception e)
            {
                e.printStackTrace();
            }
        }
    
        public boolean connect() throws RemoteException, NotBoundException
        {
            registryServer = LocateRegistry.getRegistry("localhost");
    
            chatController = (IChatController) registryServer.lookup("ChatController");
            clientController = (IClientController) registryServer.lookup("ClientController");
    
            System.out.println(userName + " fetched all controller from RMI registry");
    
            if ( clientController.join(userName, this.chatUpdate ) )
            {
                System.out.println(userName + " registered at server");
    
                return true;
            }
    
            return false;
        }
    
    
    }