Skip to content
Snippets Groups Projects
Select Git revision
  • squashed
  • master default protected
  • history
  • tourney_patches
4 results

run_fuzzer.sh

Blame
  • Forked from Toby Murray / swen90006-a2-2019
    Source project has a limited visibility.
    Client.java 2.19 KiB
    package client;
    
    import remote.IChatController;
    import remote.IClientController;
    import client.ChatUpdate;
    import GUI.StartScreen;
    
    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 Client
    {
        //test
        private String userName;
        private String serverAddress;
    
        private Registry registryServer;
        private IChatController chatController;
        private IClientController clientController;
        private ChatUpdate chatUpdate;
        private DrawingUpdate drawingUpdate;
    
        private StartScreen startScreen;
    
        public void setUsername(String userName)
        {
            this.userName = userName;
        }
    
        public void setServerAddress(String serverAddress)
        {
            this.serverAddress = serverAddress;
        }
    
        public Client() throws RemoteException
        {
            this.userName = "DefaultUser";
            this.chatUpdate = new ChatUpdate();
            this.startScreen = new StartScreen(this);
            this.drawingUpdate = new DrawingUpdate();
        }
    
        public static void main(String[] args)
        {
            try
            {
                Client client = new Client();
                client.startScreen.go();
            }
            catch (Exception e)
            {
                e.printStackTrace();
            }
        }
    
        public void run()
        {
            //connect();
    
            try
            {
                System.out.println("Sleeping...");
                TimeUnit.MINUTES.sleep(5);
            }
            catch(Exception e)
            {
                e.printStackTrace();
            }
        }
    
        public boolean connect()
        {
            try
            {
                registryServer = LocateRegistry.getRegistry(serverAddress);
    
                chatController = (IChatController) registryServer.lookup("ChatController");
                clientController = (IClientController) registryServer.lookup("ClientController");
    
                if (clientController.join(userName, this.chatUpdate, this.drawingUpdate))
                {
                    System.out.println("Connected to server");
    
                    return true;
                }
            }
            catch (Exception e)
            {
                e.printStackTrace();
            }
    
            return false;
        }
    
    
    
    
    }