Class ServerConnector

java.lang.Object
it.polimi.ingsw.network.client.ServerConnector

public class ServerConnector
extends java.lang.Object
Class that manage the connection with the server. This class receives and send Messages
  • Constructor Summary

    Constructors
    Constructor Description
    ServerConnector​(java.net.Socket server, Client client)
    Constructor for CliDrawer class
  • Method Summary

    Modifier and Type Method Description
    void handleServerConnection()
    Receives messages from server formatted in Json, de-parses them into Message class and sends them to client
    void sendToServer​(Message msg)
    Sends the message passed as parameter to server
    void stop()
    sends a quit message to server and closes client socket

    Methods inherited from class java.lang.Object

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

    • ServerConnector

      public ServerConnector​(java.net.Socket server, Client client)
      Constructor for CliDrawer class
      Parameters:
      server - , socket that connects this class to server
      client - , client's instance
  • Method Details

    • handleServerConnection

      public void handleServerConnection()
      Receives messages from server formatted in Json, de-parses them into Message class and sends them to client
    • stop

      public void stop()
      sends a quit message to server and closes client socket
    • sendToServer

      public void sendToServer​(Message msg)
      Sends the message passed as parameter to server
      Parameters:
      msg - , message to send