summaryrefslogtreecommitdiff
path: root/src/main/java/net/cshift/transit/network/INode.java
diff options
context:
space:
mode:
authorKyle Gunger <kgunger12@gmail.com>2021-05-22 13:36:56 -0400
committerKyle Gunger <kgunger12@gmail.com>2021-05-22 13:36:56 -0400
commit04276d1d18d379248cc02b17c15a28760a5adb41 (patch)
tree3cac4729c24d176af382a4031cc532ddc0827d5e /src/main/java/net/cshift/transit/network/INode.java
parentd94d1d89565998fdccff071a7c9b65ea1e264ce7 (diff)
2.0.0 alpha.predev release
Diffstat (limited to 'src/main/java/net/cshift/transit/network/INode.java')
-rw-r--r--src/main/java/net/cshift/transit/network/INode.java73
1 files changed, 73 insertions, 0 deletions
diff --git a/src/main/java/net/cshift/transit/network/INode.java b/src/main/java/net/cshift/transit/network/INode.java
new file mode 100644
index 0000000..0396347
--- /dev/null
+++ b/src/main/java/net/cshift/transit/network/INode.java
@@ -0,0 +1,73 @@
+package net.cshift.transit.network;
+
+import net.cshift.transit.network.packet.*;
+
+/**
+ * @author Kyle Gunger
+ * @apiNote A node inside or outside a system.
+ */
+public interface INode
+{
+ /** Returns true if the group given is used by the node
+ *
+ * @param group the group to query
+ * @return {@code true} if the node supports the group
+ */
+ public boolean hasGroup(String group);
+
+ /** Get the system managing the node or {@code null} if there isn't one
+ *
+ * @return System
+ */
+ public ISystem getSystem();
+
+
+
+ // ###############
+ // # Connections #
+ // ###############
+
+ /** Call this function to establish a connection with a node.
+ *
+ * @param <T> The type of connection being asked for
+ * @param group The group of connection being asked for
+ * @param asker The asking node
+ * @return A channel if the node accepts the request, {@code null} otherwise
+ */
+ public <T> Channel<T> connect(String group, INode asker);
+
+ /** Accept a packet from a channel (or not).
+ *
+ * @apiNote Do not call this function, use Channel.send(packet) instead.
+ * @param <T> The type of the packet and channel
+ * @param packet The packet to be vetted
+ * @param channel The channel which the packet is coming through
+ * @return true if the node accepts the packet
+ */
+ public <T> boolean accept(IStaticPacket<T> packet, Channel<T> channel);
+
+ /** Pressure
+ *
+ * @apiNote Do not call this function, use Channel.pressure() instead.
+ * @param channel The channel asking for the pressure
+ * @return A Number representing the pressure from the channel (in base group units).
+ */
+ public <T> Number getPressure(Channel<T> channel);
+
+ /** Transfer rate
+ *
+ * @apiNote Do not call this function, use Channel.rate() instead.
+ * @param channel The channel asking for the transfer rate
+ * @return A Number representing the transfer rate from the channel (in base group units).
+ */
+ public <T> Number getRate(Channel<T> channel);
+
+ /** Called when a channel is terminated
+ *
+ * @apiNote Do not call this function, use Channel.terminate() instead.
+ * @param <T> The type of the channel
+ * @param channel The channel being terminated
+ */
+ public <T> void onTerminate(Channel<T> channel);
+
+}