Class Client

java.lang.Object
com.example.brickpaint.Client
All Implemented Interfaces:
Runnable

public class Client extends Object implements Runnable
[WORK IN PROGRESS] Handles creation of a client connection to a corresponding server
Author:
matde
  • Constructor Summary

    Constructors
    Constructor
    Description
    Client(int port, InetAddress address, ButtonManager manager1)
    Client constructor that initializes a socket with the specified params
  • Method Summary

    Modifier and Type
    Method
    Description
    discoverServer(int port)
    Helper function that begins the discovery process and returns the designated Inetaddress of an application server if one is found, else it will throw an appropriate error
    void
    run()
    Thread method that initializes the client handler for this client
    void
    Sends an image to the connected server
    void
    Helper function that closes the client socket and handler thread

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Client

      public Client(int port, InetAddress address, ButtonManager manager1)
      Client constructor that initializes a socket with the specified params
      Parameters:
      port - The port the client should run on
      address - The Inetaddress the client should use
      manager1 - The UI Controller for the application
  • Method Details

    • discoverServer

      public static InetAddress discoverServer(int port) throws IOException
      Helper function that begins the discovery process and returns the designated Inetaddress of an application server if one is found, else it will throw an appropriate error
      Parameters:
      port - The port to look for a server on
      Returns:
      The Inetaddress of the first server found
      Throws:
      IOException - Error changes based on why the task failed
    • stop

      public void stop()
      Helper function that closes the client socket and handler thread
    • sendImageToServer

      public void sendImageToServer(BufferedImage image)
      Sends an image to the connected server
      Parameters:
      image - The image that gets sent to the server
    • run

      public void run()
      Thread method that initializes the client handler for this client
      Specified by:
      run in interface Runnable