Module AM37

Class User

java.lang.Object
it.polimi.ingsw.network.server.User

public class User
extends java.lang.Object
The entity connecting to the server; can be used to keep a game history or something similar
  • Constructor Summary

    Constructors 
    Constructor Description
    User​(VirtualClient virtualClient, Server server)
    Default constructor
  • Method Summary

    Modifier and Type Method Description
    void closeConnection()
    Ends the connection between the server and client
    Lobby getRoom()
    Provides the lobby in which the user is currently in
    java.lang.String getUsername()
    username getter
    void notify​(Message message)
    Sends a message to the client
    void setUsername​(java.lang.String username)
    username setter

    Methods inherited from class java.lang.Object

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

    • User

      public User​(VirtualClient virtualClient, Server server)
      Default constructor

      When created, a user is associated to a virtualClient, which handles all its requests

      Parameters:
      virtualClient - the virtualClient associated to the user
      server - the server reference
  • Method Details

    • getUsername

      public java.lang.String getUsername()
      username getter
      Returns:
      the user's username
    • setUsername

      public void setUsername​(java.lang.String username)
      username setter
      Parameters:
      username - the user's username
    • notify

      public void notify​(Message message)
      Sends a message to the client
      Parameters:
      message - the message to send
    • closeConnection

      public void closeConnection()
      Ends the connection between the server and client
    • getRoom

      public Lobby getRoom()
      Provides the lobby in which the user is currently in
      Returns:
      the Lobby object where this user is contained