Hi,
I noticed an issue with the way socket messages are processed on HTML5.
In socket_onMessage, it adds the new message data to __inputBuffer, then copy the whole content to __input, and reset its position.
The problem is that if the client application doesn’t read messages on every callback (e.g. on each frame instead), data can be lost.
I solved the problem by completely removing usage of __inputBuffer :
private function socket_onMessage (msg:Dynamic):Void {
#if (js && html5)
if (Std.is (msg.data, String)) {
__input.position = __input.length;
var cachePosition = __input.position;
__input.writeUTFBytes (msg.data);
__input.position = cachePosition;
} else {
var newData:ByteArray = (msg.data:ArrayBuffer);
newData.readBytes (__input, __input.length);
}
if (__input.bytesAvailable > 0) {
dispatchEvent (new ProgressEvent (ProgressEvent.SOCKET_DATA, false, false, __input.bytesAvailable, 0));
}
#end
}
Any ideas why this __inputBuffer variable is there ?