Interface WiredNode

All Superinterfaces:
PacketNetwork

@NonExtendable public interface WiredNode extends PacketNetwork
Wired nodes act as a layer between WiredElements and WiredNetworks.

Firstly, a node acts as a packet network, capable of sending and receiving modem messages to connected nodes. These methods may be safely used on any thread.

When sending a packet, the system will attempt to find the shortest path between the two nodes based on their element's position. Note that packet senders and receivers can have different locations from their associated element: the distance between the two will be added to the total packet's distance.

Wired nodes also provide several convenience methods for interacting with a wired network. These should only ever be used on the main server thread.

  • Method Details

    • getElement

      WiredElement getElement()
      The associated element for this network node.
      Returns:
      This node's element.
    • getNetwork

      Deprecated.
      Use the connect/disconnect/remove methods on WiredNode.
      The network this node is currently connected to. Note that this may change after any network operation, so it should not be cached.

      This should only be used on the server thread.

      Returns:
      This node's network.
    • connectTo

      boolean connectTo(WiredNode node)
      Create a connection from this node to another.

      This should only be used on the server thread.

      Parameters:
      node - The other node to connect to.
      Returns:
      true if a connection was created or false if the connection already exists.
      See Also:
    • disconnectFrom

      boolean disconnectFrom(WiredNode node)
      Destroy a connection between this node and another.

      This should only be used on the server thread.

      Parameters:
      node - The other node to disconnect from.
      Returns:
      true if a connection was destroyed or false if no connection exists.
      See Also:
    • remove

      boolean remove()
      Sever all connections this node has, removing it from this network.

      This should only be used on the server thread. You should only call this on nodes that your network element owns.

      Returns:
      Whether this node was removed from the network. One cannot remove a node from a network where it is the only element.
      Throws:
      IllegalArgumentException - If the node is not in the network.
    • updatePeripherals

      void updatePeripherals(Map<String,IPeripheral> peripherals)
      Mark this node's peripherals as having changed.

      This should only be used on the server thread. You should only call this on nodes that your network element owns.

      Parameters:
      peripherals - The new peripherals for this node.