Class CompositeClientBroadcaster

java.lang.Object
it.polimi.ingsw.gc14.Network.CompositeClientBroadcaster

public class CompositeClientBroadcaster extends Object
Forwards every notification to both the RMI and the TCP transport layers.

This follows the Composite pattern: the caller interacts with a single broadcaster without knowing which protocols are active underneath.

  • Field Details

    • rmiServer

      private final RMIServer rmiServer
      RMI transport used to reach RMI-connected clients.
    • tcpServer

      private final TCPServer tcpServer
      TCP transport used to reach TCP-connected clients.
  • Constructor Details

    • CompositeClientBroadcaster

      public CompositeClientBroadcaster(RMIServer rmiServer, TCPServer tcpServer)
      Constructs a composite broadcaster backed by the given RMI and TCP servers.
      Parameters:
      rmiServer - the RMI server used to reach RMI clients.
      tcpServer - the TCP server used to reach TCP clients.
  • Method Details

    • notifyAll

      public void notifyAll(NetworkEvent event)
      Forwards the event to both the RMI and the TCP server. Each server is responsible for filtering error events to the requesting player only.
      Parameters:
      event - the network event to broadcast.
    • notifyAll

      public void notifyAll(MiniModel model)
      Forwards the model snapshot to every client on both transports.
      Parameters:
      model - the mini model snapshot to broadcast.