From c05689ba385733ee52ca825b194134126640af8a Mon Sep 17 00:00:00 2001 From: Kyle Gunger Date: Fri, 22 Nov 2019 10:35:21 -0500 Subject: [Update] Nodes now transfer things ~ Switched Provider and Acceptor to ProviderNode and AcceptorNode ~ Nodes are now expected to connect to eachother on their own ~ Inventory hooks are not here, but have been thought through Signed-off-by: Kyle Gunger --- gradle.properties | 2 +- .../java/net/transit/network/swap/Acceptor.java | 44 ------------------- .../java/net/transit/network/swap/Provider.java | 50 ---------------------- src/main/java/net/transit/network/system/Node.java | 36 ++++------------ .../transit/network/system/swap/AcceptorNode.java | 31 ++++++++++++++ .../transit/network/system/swap/ProviderNode.java | 20 +++++++++ 6 files changed, 60 insertions(+), 123 deletions(-) delete mode 100644 src/main/java/net/transit/network/swap/Acceptor.java delete mode 100644 src/main/java/net/transit/network/swap/Provider.java create mode 100644 src/main/java/net/transit/network/system/swap/AcceptorNode.java create mode 100644 src/main/java/net/transit/network/system/swap/ProviderNode.java diff --git a/gradle.properties b/gradle.properties index fca60ca..7684a47 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,7 +8,7 @@ org.gradle.jvmargs=-Xmx1G loader_version=0.6.1+build.164 # Mod Properties - mod_version = 0.2.8 + mod_version = 0.3.1 maven_group = net.transit archives_base_name = transit-api diff --git a/src/main/java/net/transit/network/swap/Acceptor.java b/src/main/java/net/transit/network/swap/Acceptor.java deleted file mode 100644 index 9778095..0000000 --- a/src/main/java/net/transit/network/swap/Acceptor.java +++ /dev/null @@ -1,44 +0,0 @@ -package net.transit.network.swap; - -import net.transit.network.packet.Packet; -import net.transit.network.system.Node; - -/** - * @author Kyle Gunger - * - * @param The type of data accepted (in IPacket<> form) - */ -public interface Acceptor -{ - /** Returns the INode this Acceptor is attached to. All Acceptors and Provider must be attached to an INode to function. - * - * @return INode - */ - public Node getNode(); - - /** - * @return True if the Acceptor can accept packets. - */ - public boolean canAccept(); - - /** - * @param provided The packet provided. - * @return True if the Acceptor accepted the packet. - */ - public boolean accept(Packet provided); - - /** - * @return True if the Acceptor has a Provider assigned to it. - */ - public boolean hasProvider(); - - /**Set the provider of the Acceptor. The Acceptor can decide if it wants to adopt the Provider. - */ - public void setProvider(Provider provider); - - /** Request that the Acceptor close it's connection to a Provider. The Acceptor may also shut itself down if no more Providers are attached. - * - * @param provider The Provider - */ - public void shutdown(Provider provider); -} \ No newline at end of file diff --git a/src/main/java/net/transit/network/swap/Provider.java b/src/main/java/net/transit/network/swap/Provider.java deleted file mode 100644 index 20656b8..0000000 --- a/src/main/java/net/transit/network/swap/Provider.java +++ /dev/null @@ -1,50 +0,0 @@ -package net.transit.network.swap; - -import net.transit.network.packet.Packet; -import net.transit.network.system.Node; - -/** - * @author Kyle Gunger - * - * @param The type of data provided (in IPacket<> form) - */ -public interface Provider -{ - /** Returns the INode this Provider is attached to. All Acceptors and Providers must be attached to an INode to function. - * - * @return INode - */ - public Node getNode(); - - /** - * @return True if the Provider can provide a packet. - */ - public boolean canProvide(); - - /**Get the next packet from the Provider - * - * @return IPacket<> - */ - public Packet provide(); - - /**Retain the packet if the Acceptor did not accept the packet. - * - * @param rejected The rejected packet - */ - public void retain(Packet rejected); - - /** - * @return True if the Provider has an Acceptor assigned to it - */ - public boolean hasAcceptor(); - - /**Set the Acceptor of the Provider. The Provider can decide if it wants to adopt the Acceptor. - */ - public void setAcceptor(Acceptor acceptor); - - /** Request that the Provider close it's connection to a Acceptor. The Provider may also shut itself down if no more Acceptors are attached. - * - * @param acceptor The Acceptor - */ - public void shutdown(Acceptor acceptor); -} \ No newline at end of file diff --git a/src/main/java/net/transit/network/system/Node.java b/src/main/java/net/transit/network/system/Node.java index 8e0fcbb..9e9ac10 100644 --- a/src/main/java/net/transit/network/system/Node.java +++ b/src/main/java/net/transit/network/system/Node.java @@ -1,50 +1,30 @@ package net.transit.network.system; -import net.transit.network.swap.Acceptor; -import net.transit.network.swap.Provider; - /** * @author Kyle Gunger * @apiNote A node inside or outside a system. Provides acceptors and providers to other nodes. */ public interface Node { - /**Returns the groupIDs of groups the node provide + + /**Returns the groupIDs of groups the node interacts with * * @return String[] */ public String[] groupsProvided(); + /**Get the system managing the node or {@code null} if there isn't one * - * @return ISystem + * @return System */ public System getSystem(); - /**Returns {@code true} if the node provides Acceptors - * - * @return boolean - */ - public boolean isAcceptor(); - - /**Returns an Acceptor or {@code null} depending on the requester and group - * - * @param requester The object requesting the Acceptor - * @param group - * @return Acceptor - */ - public Acceptor requestAcceptor(Object requester, String group); - - /**Returns {@code true} if the node provides Providers - * - */ - public boolean isProvider(); - /**Returns an Provider or {@code null} depending on the requester and group + /** Get the data of one of the TypeGroups the Node supports * - * @param requester The object requesting the Provider - * @param group - * @return Provider + * @param groupID + * @return */ - public Provider requestProvider(Object requestor, String group); + public Object getData(String groupID); } diff --git a/src/main/java/net/transit/network/system/swap/AcceptorNode.java b/src/main/java/net/transit/network/system/swap/AcceptorNode.java new file mode 100644 index 0000000..c583146 --- /dev/null +++ b/src/main/java/net/transit/network/system/swap/AcceptorNode.java @@ -0,0 +1,31 @@ +package net.transit.network.system.swap; + +import net.transit.network.packet.Packet; +import net.transit.network.system.Node; + +public interface AcceptorNode extends Node +{ + + /** Link another node as a provider + * + * @param requester The object to be a provider + * @param group + * @return Provider + */ + public boolean linkProvider(Node requestor, String group); + + + /** + * @return Node[] + */ + public Node[] getProviders(); + + + /** Accept a packet from a provider + * + * @param packet + * @param group + * @return + */ + public boolean accept(Packet packet, String group); +} diff --git a/src/main/java/net/transit/network/system/swap/ProviderNode.java b/src/main/java/net/transit/network/system/swap/ProviderNode.java new file mode 100644 index 0000000..4cd9dba --- /dev/null +++ b/src/main/java/net/transit/network/system/swap/ProviderNode.java @@ -0,0 +1,20 @@ +package net.transit.network.system.swap; + +import net.transit.network.system.Node; + +public interface ProviderNode extends Node{ + + /** Link another node as an acceptor + * + * @param requester The object requesting the Acceptor + * @param group + * @return boolean + */ + public boolean linkAcceptor(Node requester, String group); + + /** + * @return Node[] + */ + public Node[] getAcceptors(); + +} -- cgit v1.2.3