Class RemoteGameController

java.lang.Object
tech.underoaks.coldcase.remote.RemoteGameController
All Implemented Interfaces:
AutoCloseable

public class RemoteGameController extends Object implements AutoCloseable
Represents a remote game controller responsible for managing remote interactions and game state updates through WebSocket communication.

This class handles the creation and management of interaction chains and provides functionality to trigger actions remotely and apply or abort updates to the game state.

  • Constructor Summary

    Constructors
    Constructor
    Description
    Initializes a new remote game controller, establishing a remote interaction chain and retrieving its unique identifier.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Applies all pending updates in the game state update (GSU) queue for the remote interaction chain on the other client.
    void
    Closes the remote game controller and aborts any pending updates in the GSU queue.
    Triggers a remote action at the specified position and direction.
    triggerAction(Interaction interaction, boolean suppressTranscendentFollowUp)
    Triggers a remote action at the specified position and direction with an option to suppress follow-up actions.

    Methods inherited from class java.lang.Object

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

    • RemoteGameController

      public RemoteGameController() throws TimeoutException
      Initializes a new remote game controller, establishing a remote interaction chain and retrieving its unique identifier.

      blocks until timeout or responseMessage completes the futureObj.

      Throws:
      TimeoutException - if no response is being returned
  • Method Details

    • triggerAction

      public Queue<Interaction> triggerAction(Interaction interaction)
      Triggers a remote action at the specified position and direction.
      Parameters:
      interaction - The interaction to trigger.
      Returns:
      a queue of interactions representing the result of the triggered action, or null if the action times out, an error occurs or no Action took place.
    • triggerAction

      public Queue<Interaction> triggerAction(Interaction interaction, boolean suppressTranscendentFollowUp)
      Triggers a remote action at the specified position and direction with an option to suppress follow-up actions.

      needed to not create an endless loop of creating remote interaction chains.

      Parameters:
      interaction - The interaction to trigger.
      suppressTranscendentFollowUp - whether to suppress follow-up actions.
      Returns:
      a queue of interactions representing the result of the triggered action, or null if the action times out or an error occurs.
    • applyGSUQueue

      public void applyGSUQueue()
      Applies all pending updates in the game state update (GSU) queue for the remote interaction chain on the other client.
    • close

      public void close()
      Closes the remote game controller and aborts any pending updates in the GSU queue.
      Specified by:
      close in interface AutoCloseable