Browse Source

Fixed protocol bugs

master
Thomas Johnson 2 years ago
parent
commit
c03a0be58f
  1. 2
      proto/ProtoIn.java
  2. 2
      proto/ProtoOut.java

2
proto/ProtoIn.java

@ -70,7 +70,7 @@ public class ProtoIn
int nLength = Byte.toUnsignedInt(dis.readByte());
byte bytes[] = new byte[nLength];
dis.read(bytes, 0, nLength);
a += nLength;
a += nLength + 1;
names.add(new String(bytes, "UTF-8"));
}
handler.handleListing(username, names);

2
proto/ProtoOut.java

@ -81,7 +81,7 @@ public class ProtoOut
{
out.writeByte(ProtoID.LISTING.b);
// I can recognize bad code when I write it, and this is bad code.
out.writeInt(names.stream().collect(Collectors.summingInt((s) -> s.getBytes().length)));
out.writeInt(names.size() + names.stream().collect(Collectors.summingInt((s) -> s.getBytes().length)));
writeUserName(username);
for (String n : names)
{

Loading…
Cancel
Save