Skip to content

Commit

Permalink
More minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ME1312 committed Feb 22, 2023
1 parent 192a6e0 commit 19dbfd3
Show file tree
Hide file tree
Showing 14 changed files with 31 additions and 33 deletions.
6 changes: 3 additions & 3 deletions Client/api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
<dependencies>
<dependency>
<groupId>net.ME1312.Galaxi</groupId>
<artifactId>GalaxiUtil</artifactId>
<version>22w11a</version>
<artifactId>GalaxiBase</artifactId>
<version>23w08a</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -98,7 +98,7 @@
<reportOutputDirectory>${basedir}/../../Javadoc/ClientAPI</reportOutputDirectory>
<additionalOptions>-Xdoclint:none</additionalOptions>
<links>
<link>https://dev.me1312.net/jenkins/job/GalaxiEngine/javadoc/GalaxiUtil/</link>
<link>https://dev.me1312.net/jenkins/job/GalaxiEngine/javadoc/GalaxiBase/</link>
</links>
</configuration>
</execution>
Expand Down
6 changes: 3 additions & 3 deletions Client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
<dependencies>
<dependency>
<groupId>net.ME1312.Galaxi</groupId>
<artifactId>GalaxiUtil</artifactId>
<version>22w11a</version>
<artifactId>GalaxiBase</artifactId>
<version>23w08a</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -124,7 +124,7 @@
<dependencySourceInclude>net.ME1312.SubData:ClientAPI:*</dependencySourceInclude>
</dependencySourceIncludes>
<links>
<link>https://dev.me1312.net/jenkins/job/GalaxiEngine/javadoc/GalaxiUtil/</link>
<link>https://dev.me1312.net/jenkins/job/GalaxiEngine/javadoc/GalaxiBase/</link>
</links>
</configuration>
</execution>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ private void flush() {
} else shutdown.run();
}
}
private long flushMBB() throws IOException {
private int flushMBB() throws IOException {
int size = Math.min((int) Math.floor((double) stored / MBB), 256);
int length = size * MBB;
out.write('\u0013');
Expand All @@ -130,7 +130,7 @@ private long flushMBB() throws IOException {
cursor += length;
return length;
}
private long flushKBB() throws IOException {
private int flushKBB() throws IOException {
int size = Math.min((int) Math.floor((double) stored / KBB), 256);
int length = size * KBB;
out.write('\u0012');
Expand All @@ -139,7 +139,7 @@ private long flushKBB() throws IOException {
cursor += length;
return length;
}
private long flushBB() throws IOException {
private int flushBB() throws IOException {
int size = Math.min((int) Math.floor((double) stored / BB), 256);
int length = size * BB;
out.write('\u0011');
Expand All @@ -148,7 +148,7 @@ private long flushBB() throws IOException {
cursor += length;
return length;
}
private long flushByte() throws IOException {
private int flushByte() throws IOException {
out.write('\u0010');
out.write(block[cursor++]);
return 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ public void send(SubDataSender sender, OutputStream out) throws Throwable {
out.close();
}

@SuppressWarnings("unchecked")
@Override
public void receive(SubDataSender sender, InputStream in) throws Throwable {
ByteBuffer data = ByteBuffer.allocate(32).order(ByteOrder.BIG_ENDIAN);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ public void receive(SubDataSender sender, InputStream data) throws Throwable {
if (!mIn.keySet().contains(channel) || !mIn.get(channel).keySet().contains(handle)) throw new IllegalMessageException("Could not find handler for message: [\"" + channel + "\", \"" + handle + "\"]");

MessageIn message = mIn.get(channel).get(handle);
if (sender instanceof ForwardedDataSender && !(message instanceof Forwardable)) throw new IllegalSenderException("This handler does not support forwarded messages: [" + message.getClass().getCanonicalName() + "]");
if (sender instanceof SubDataClient && message instanceof ForwardOnly) throw new IllegalSenderException("This handler does not support non-forwarded messages: [" + message.getClass().getCanonicalName() + "]");
if (sender instanceof ForwardedDataSender && !(message instanceof Forwardable)) throw new IllegalSenderException("This handler does not support forwarded messages: [" + message.getClass().getTypeName() + "]");
if (sender instanceof SubDataClient && message instanceof ForwardOnly) throw new IllegalSenderException("This handler does not support non-forwarded messages: [" + message.getClass().getTypeName() + "]");
message.receive(sender);
if (message instanceof MessageStreamIn) ((MessageStreamIn) message).receive(sender, data);
else data.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public PacketSendMessage(MessageOut message) {
public void send(SubDataSender sender, OutputStream data) throws Throwable {
HashMap<Class<? extends MessageOut>, Pair<String, String>> mOut = Util.reflect(DataProtocol.class.getDeclaredField("mOut"), sender.getProtocol());

if (!mOut.containsKey(message.getClass())) throw new IllegalMessageException("Could not find handle for message: " + message.getClass().getCanonicalName());
if (!mOut.containsKey(message.getClass())) throw new IllegalMessageException("Could not find handle for message: " + message.getClass().getTypeName());

EscapedOutputStream out = new EscapedOutputStream(data, '\u001B', '\u0003');
out.write(mOut.get(message.getClass()).key().getBytes(StandardCharsets.UTF_8));
Expand Down
8 changes: 4 additions & 4 deletions Client/src/net/ME1312/SubData/Client/SubDataClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,12 @@ public void close() throws IOException {
HashMap<Integer, PacketIn> pIn = (state.asInt() >= POST_INITIALIZATION.asInt())?protocol.pIn:Util.reflect(InitialProtocol.class.getDeclaredField("pIn"), null);
if (!pIn.keySet().contains(id)) throw new IllegalPacketException(address.toString() + ": Could not find handler for packet: [" + DebugUtil.toHex(0xFFFF, id) + "]");
PacketIn packet = pIn.get(id);
if (sender instanceof ForwardedDataSender && !(packet instanceof Forwardable)) throw new IllegalSenderException(address.toString() + ": This handler does not support forwarded packets: [" + packet.getClass().getCanonicalName() + "]");
if (sender instanceof SubDataClient && packet instanceof ForwardOnly) throw new IllegalSenderException(address.toString() + ": This handler does not support non-forwarded packets: [" + packet.getClass().getCanonicalName() + "]");
if (sender instanceof ForwardedDataSender && !(packet instanceof Forwardable)) throw new IllegalSenderException(address.toString() + ": This handler does not support forwarded packets: [" + packet.getClass().getTypeName() + "]");
if (sender instanceof SubDataClient && packet instanceof ForwardOnly) throw new IllegalSenderException(address.toString() + ": This handler does not support non-forwarded packets: [" + packet.getClass().getTypeName() + "]");

// Step 5 // Invoke the Packet
if (state == PRE_INITIALIZATION && !(packet instanceof InitPacketDeclaration)) {
throw new ProtocolException(address.toString() + ": Only " + InitPacketDeclaration.class.getCanonicalName() + " may be received during the PRE_INITIALIZATION stage: [" + packet.getClass().getCanonicalName() + "]");
throw new ProtocolException(address.toString() + ": Only " + InitPacketDeclaration.class.getTypeName() + " may be received during the PRE_INITIALIZATION stage: [" + packet.getClass().getTypeName() + "]");
} else if (state == CLOSING && !(packet instanceof PacketDisconnectUnderstood)) {
forward.close(); // Suppress other packets during the CLOSING stage
} else {
Expand Down Expand Up @@ -256,7 +256,7 @@ public void close() throws IOException {
};
// Step 2 // Write the Packet Metadata
HashMap<Class<? extends PacketOut>, Integer> pOut = (state.asInt() >= POST_INITIALIZATION.asInt())?protocol.pOut:Util.reflect(InitialProtocol.class.getDeclaredField("pOut"), null);
if (!pOut.keySet().contains(next.getClass())) throw new IllegalMessageException(address.toString() + ": Could not find ID for packet: " + next.getClass().getCanonicalName());
if (!pOut.keySet().contains(next.getClass())) throw new IllegalMessageException(address.toString() + ": Could not find ID for packet: " + next.getClass().getTypeName());

data.write(UnsignedData.unsign((long) pOut.get(next.getClass()), 2), 0, 2);
data.flush();
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ Apache License
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright (C) 2019-2021 ME1312
Copyright (C) 2019-2023 ME1312

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
6 changes: 3 additions & 3 deletions Server/api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
<dependencies>
<dependency>
<groupId>net.ME1312.Galaxi</groupId>
<artifactId>GalaxiUtil</artifactId>
<version>22w11a</version>
<artifactId>GalaxiBase</artifactId>
<version>23w08a</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -98,7 +98,7 @@
<reportOutputDirectory>${basedir}/../../Javadoc/ServerAPI</reportOutputDirectory>
<additionalOptions>-Xdoclint:none</additionalOptions>
<links>
<link>https://dev.me1312.net/jenkins/job/GalaxiEngine/javadoc/GalaxiUtil/</link>
<link>https://dev.me1312.net/jenkins/job/GalaxiEngine/javadoc/GalaxiBase/</link>
</links>
</configuration>
</execution>
Expand Down
6 changes: 3 additions & 3 deletions Server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
<dependencies>
<dependency>
<groupId>net.ME1312.Galaxi</groupId>
<artifactId>GalaxiUtil</artifactId>
<version>22w11a</version>
<artifactId>GalaxiBase</artifactId>
<version>23w08a</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -124,7 +124,7 @@
<dependencySourceInclude>net.ME1312.SubData:ServerAPI:*</dependencySourceInclude>
</dependencySourceIncludes>
<links>
<link>https://dev.me1312.net/jenkins/job/GalaxiEngine/javadoc/GalaxiUtil/</link>
<link>https://dev.me1312.net/jenkins/job/GalaxiEngine/javadoc/GalaxiBase/</link>
</links>
</configuration>
</execution>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ private void flush() {
} else shutdown.run();
}
}
private long flushMBB() throws IOException {
private int flushMBB() throws IOException {
int size = Math.min((int) Math.floor((double) stored / MBB), 256);
int length = size * MBB;
out.write('\u0013');
Expand All @@ -130,7 +130,7 @@ private long flushMBB() throws IOException {
cursor += length;
return length;
}
private long flushKBB() throws IOException {
private int flushKBB() throws IOException {
int size = Math.min((int) Math.floor((double) stored / KBB), 256);
int length = size * KBB;
out.write('\u0012');
Expand All @@ -139,7 +139,7 @@ private long flushKBB() throws IOException {
cursor += length;
return length;
}
private long flushBB() throws IOException {
private int flushBB() throws IOException {
int size = Math.min((int) Math.floor((double) stored / BB), 256);
int length = size * BB;
out.write('\u0011');
Expand All @@ -148,7 +148,7 @@ private long flushBB() throws IOException {
cursor += length;
return length;
}
private long flushByte() throws IOException {
private int flushByte() throws IOException {
out.write('\u0010');
out.write(block[cursor++]);
return 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ public void send(SubDataClient client, OutputStream out) throws Throwable {
out.close();
}

@SuppressWarnings("unchecked")
@Override
public void receive(SubDataClient client, InputStream in) throws Throwable {
ByteBuffer data = ByteBuffer.allocate(32).order(ByteOrder.BIG_ENDIAN);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public PacketSendMessage(MessageOut message) {
public void send(SubDataClient client, OutputStream data) throws Throwable {
HashMap<Class<? extends MessageOut>, Pair<String, String>> mOut = Util.reflect(DataProtocol.class.getDeclaredField("mOut"), client.getServer().getProtocol());

if (!mOut.containsKey(message.getClass())) throw new IllegalMessageException("Could not find handle for message: " + message.getClass().getCanonicalName());
if (!mOut.containsKey(message.getClass())) throw new IllegalMessageException("Could not find handle for message: " + message.getClass().getTypeName());

EscapedOutputStream out = new EscapedOutputStream(data, '\u001B', '\u0003');
out.write(mOut.get(message.getClass()).key().getBytes(StandardCharsets.UTF_8));
Expand Down
4 changes: 2 additions & 2 deletions Server/src/net/ME1312/SubData/Server/SubDataClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public void close() throws IOException {

// Step 5 // Invoke the Packet
if (state == PRE_INITIALIZATION && !(packet instanceof InitPacketDeclaration)) {
throw new ProtocolException(address.toString() + ": Only " + InitPacketDeclaration.class.getCanonicalName() + " may be received during the PRE_INITIALIZATION stage: [" + packet.getClass().getCanonicalName() + "]");
throw new ProtocolException(address.toString() + ": Only " + InitPacketDeclaration.class.getTypeName() + " may be received during the PRE_INITIALIZATION stage: [" + packet.getClass().getTypeName() + "]");
} else if (state == CLOSING && !(packet instanceof PacketDisconnectUnderstood)) {
forward.close(); // Suppress other packets during the CLOSING stage
} else {
Expand Down Expand Up @@ -249,7 +249,7 @@ public void close() throws IOException {
};
// Step 2 // Write the Packet Metadata
HashMap<Class<? extends PacketOut>, Integer> pOut = (state.asInt() >= POST_INITIALIZATION.asInt())?subdata.protocol.pOut:Util.reflect(InitialProtocol.class.getDeclaredField("pOut"), null);
if (!pOut.containsKey(next.getClass())) throw new IllegalMessageException(address.toString() + ": Could not find ID for packet: " + next.getClass().getCanonicalName());
if (!pOut.containsKey(next.getClass())) throw new IllegalMessageException(address.toString() + ": Could not find ID for packet: " + next.getClass().getTypeName());

data.write(UnsignedData.unsign((long) pOut.get(next.getClass()), 2), 0, 2);
data.flush();
Expand Down

0 comments on commit 19dbfd3

Please sign in to comment.