summaryrefslogtreecommitdiff
path: root/src/main/java/net/cshift
diff options
context:
space:
mode:
authorKyle Gunger <kgunger12@gmail.com>2021-05-31 17:14:46 -0400
committerKyle Gunger <kgunger12@gmail.com>2021-05-31 17:14:46 -0400
commit9190d7c12d1bbdcfc401543128fb0219e6fc0a81 (patch)
tree15c3a46a936f619ab9ee3d7039e88dbcf1a51d69 /src/main/java/net/cshift
parent04276d1d18d379248cc02b17c15a28760a5adb41 (diff)
alpha.predev.2
Diffstat (limited to 'src/main/java/net/cshift')
-rw-r--r--src/main/java/net/cshift/transit/network/Channel.java7
-rw-r--r--src/main/java/net/cshift/transit/network/INode.java10
-rw-r--r--src/main/java/net/cshift/transit/network/PoolManifest.java36
-rw-r--r--src/main/java/net/cshift/transit/type/group/TypeGroup.java11
4 files changed, 47 insertions, 17 deletions
diff --git a/src/main/java/net/cshift/transit/network/Channel.java b/src/main/java/net/cshift/transit/network/Channel.java
index 43dbabc..c7be552 100644
--- a/src/main/java/net/cshift/transit/network/Channel.java
+++ b/src/main/java/net/cshift/transit/network/Channel.java
@@ -7,7 +7,7 @@ import net.cshift.transit.network.packet.IStaticPacket;
* @apiNote A channel represents a connection between two nodes. It is able to send data in packets, and serves as a way to organize incoming traffic.
* @param <D> The type of data the packets will be transfering
*/
-public class Channel<D> {
+public final class Channel<D> {
private INode to;
private int id;
private String group;
@@ -16,7 +16,7 @@ public class Channel<D> {
* Negative IDs indicate a terminated connection, so do not initialize the class with a negative ID.
*
* @param node The recieving node
- * @param id The channel's id, as assigned by the recieving node.
+ * @param id The channel's id, as assigned by the recieving node. In most cases, this will match the pool ID as a way to match channels to pools.
* @param group
*/
public Channel(INode node, int id, String group)
@@ -75,6 +75,7 @@ public class Channel<D> {
/** Pressure
*
+ * @apiNote This part of the api is not properly documented yet, and it's use is not reccommended for cross-mod communications.
* @return A Number representing the pressure from the channel (in base group units).
*/
public Number pressure()
@@ -84,7 +85,7 @@ public class Channel<D> {
/** Max transfer rate
*
- * @return A Number representing the max transfer rate from the channel (in base group units).
+ * @return A Number representing the max transfer rate from the channel (in base group units per tick).
*/
public Number rate()
{
diff --git a/src/main/java/net/cshift/transit/network/INode.java b/src/main/java/net/cshift/transit/network/INode.java
index 0396347..8f74dd6 100644
--- a/src/main/java/net/cshift/transit/network/INode.java
+++ b/src/main/java/net/cshift/transit/network/INode.java
@@ -8,12 +8,10 @@ import net.cshift.transit.network.packet.*;
*/
public interface INode
{
- /** Returns true if the group given is used by the node
+ /** Returns a channel manifest for the INode
*
- * @param group the group to query
- * @return {@code true} if the node supports the group
*/
- public boolean hasGroup(String group);
+ public PoolManifest getManifest();
/** Get the system managing the node or {@code null} if there isn't one
*
@@ -34,7 +32,7 @@ public interface INode
* @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);
+ public <T> Channel<T> connect(int poolID, INode asker);
/** Accept a packet from a channel (or not).
*
@@ -58,7 +56,7 @@ public interface INode
*
* @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).
+ * @return A Number representing the transfer rate from the channel (in base group units per tick).
*/
public <T> Number getRate(Channel<T> channel);
diff --git a/src/main/java/net/cshift/transit/network/PoolManifest.java b/src/main/java/net/cshift/transit/network/PoolManifest.java
new file mode 100644
index 0000000..d6bec43
--- /dev/null
+++ b/src/main/java/net/cshift/transit/network/PoolManifest.java
@@ -0,0 +1,36 @@
+package net.cshift.transit.network;
+
+/**
+ * @author Kyle Gunger
+ * @apiNote A channel manifest represents a set of possible data/resource pools that another node can request a channel to.
+ */
+public interface PoolManifest {
+
+ /** Represents the number of pools that the node has access to for the specified resource.
+ * @apiNote A "pool" in this context represents an independant network of resources.
+ * Pool zero should be the default group that simple nodes will attempt to connect to.
+ * @param group The TypeGroup that the pool belongs to
+ */
+ public int poolCount(String group);
+
+ /** The ID of the pool. The INode will use this in a connection attempt with the other INode.
+ *
+ * @param group The TypeGroup the pool belongs to
+ * @param pool Array-like index for pool (gotten from poolCount)
+ */
+ public int poolID(String group, int pool);
+
+ /** If the mod supports named pools, the names can be querried through this function.
+ *
+ * @param group The TypeGroup the pool belongs to
+ * @param pool Array-like index for pool (gotten from poolCount)
+ */
+ public String poolName(String group, int pool);
+
+ /** If the mod supports pool descriptions, they can be accessed by this method.
+ *
+ * @param group The TypeGroup the pool belongs to
+ * @param pool Array-like index for pool (gotten from poolCount)
+ */
+ public String poolDescription(String group, int pool);
+}
diff --git a/src/main/java/net/cshift/transit/type/group/TypeGroup.java b/src/main/java/net/cshift/transit/type/group/TypeGroup.java
index 596a511..d120cba 100644
--- a/src/main/java/net/cshift/transit/type/group/TypeGroup.java
+++ b/src/main/java/net/cshift/transit/type/group/TypeGroup.java
@@ -204,12 +204,7 @@ public class TypeGroup<B>
@Deprecated
public IStaticPacket<B> convertPacket(IStaticPacket<B> packet, Type<B> type)
{
- if(isInGroup(packet.getType()) && isInGroup(type))
- {
- return convertPacketRaw(packet, type);
- }
-
- return null;
+ return type.convertFrom(packet, this.getGroup());
}
/**Convert a packet to a new type Returns null if the type isn't found.
@@ -225,7 +220,7 @@ public class TypeGroup<B>
Type<B> toType = getType(groupID, typeID);
if(toType != null)
{
- return convertPacketRaw(packet, toType);
+ return toType.convertFrom(packet, this.getGroup());
}
return null;
@@ -243,7 +238,7 @@ public class TypeGroup<B>
Type<B> toType = getType(typeID);
if(toType != null)
{
- return convertPacketRaw(packet, toType);
+ return toType.convertFrom(packet, this.getGroup());
}
return null;