Skip to content

Commit

Permalink
Merge pull request #1020 from penguinlab/master
Browse files Browse the repository at this point in the history
Fixed a problem that connection from Socket.IO Client v2 failed.
  • Loading branch information
mrniko authored Nov 29, 2024
2 parents 49ed3b7 + db0124f commit 37a6312
Showing 1 changed file with 10 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -307,23 +307,18 @@ private String readNamespace(ByteBuf frame, final boolean defaultToAll) {
*/
ByteBuf buffer = frame.slice();

int namespaceFieldEndIndex = buffer.bytesBefore((byte) ',');
namespaceFieldEndIndex = namespaceFieldEndIndex > 0 ? namespaceFieldEndIndex : buffer.readableBytes();

int endIndex = buffer.bytesBefore((byte) '?');
if (endIndex > 0) {
String namespace = readString(buffer, endIndex);
if(namespace.startsWith("/")) {
frame.skipBytes(endIndex + 1);
return namespace;
}
}
endIndex = buffer.bytesBefore((byte) ',');
if (endIndex > 0) {
String namespace = readString(buffer, endIndex);
if(namespace.startsWith("/")) {
frame.skipBytes(endIndex + 1);
return namespace;
}
int namespaceEndIndex = buffer.bytesBefore((byte) '?');
namespaceEndIndex = namespaceEndIndex > 0 ? namespaceEndIndex : namespaceFieldEndIndex;

String namespace = readString(buffer, namespaceEndIndex);
if (namespace.startsWith("/")) {
frame.skipBytes(namespaceFieldEndIndex + 1);
return namespace;
}

if (defaultToAll) {
// skip this frame
frame.skipBytes(frame.readableBytes());
Expand Down

0 comments on commit 37a6312

Please sign in to comment.