-
Notifications
You must be signed in to change notification settings - Fork 1.7k
fix attachment lose #900 #918
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Thank you for the suggested changes. Is the problem in empty byte arrays handling? I see your code does the same except empty byte arrays filtering |
Thanks for asking, I found two problems when I send byte[] message.
|
3c3a76b
to
115cf42
Compare
@@ -22,9 +22,14 @@ | |||
import com.corundumstudio.socketio.store.StoreFactory; | |||
import com.corundumstudio.socketio.store.pubsub.DispatchMessage; | |||
import com.corundumstudio.socketio.store.pubsub.PubSubType; | |||
import io.netty.buffer.Unpooled; | |||
import org.springframework.lang.NonNull; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spring package can't be used
@@ -259,7 +259,7 @@ private void handleWebsocket(final OutPacketMessage msg, ChannelHandlerContext c | |||
for (ByteBuf buf : packet.getAttachments()) { | |||
ByteBuf outBuf = encoder.allocateBuffer(ctx.alloc()); | |||
outBuf.writeByte(4); | |||
outBuf.writeBytes(buf); | |||
outBuf.writeBytes(buf, 0, buf.readableBytes()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is what outBuf.writeBytes(buf) exactly does
List<byte[]> bytes = Arrays.stream(data) | ||
.filter(o -> o instanceof byte[]) | ||
.map(b -> (byte[]) b) | ||
.filter(b -> b.length > 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there are no empty byte arrays
|
||
if (!CollectionUtils.isEmpty(bytes)) { | ||
packet.initAttachments(bytes.size()); | ||
bytes.stream().peek(b -> packet.addAttachment(Unpooled.wrappedBuffer(b))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the same is done in encodePacket() method
Fix the problem that when broadcasting a byte array data to multiple clients in the same room, the client receives 450, 452 and other wrong binaryEvent number messages and has 45x probe header messages missing attachments