Websocket peer outbound buffer fixes. Expose outbound buffered amount.

This commit is contained in:
Jordan Schidlowsky 2021-07-29 14:11:27 -06:00
parent 44012fa61d
commit de02cf44ae
10 changed files with 56 additions and 4 deletions

View file

@ -101,6 +101,15 @@ const GodotWebSocket = {
return 0;
},
// Get current bufferedAmount
bufferedAmount: function (p_id) {
const ref = IDHandler.get(p_id);
if (!ref) {
return 0; // Godot object is gone.
}
return ref.bufferedAmount;
},
create: function (socket, p_on_open, p_on_message, p_on_error, p_on_close) {
const id = IDHandler.add(socket);
socket.onopen = GodotWebSocket._onopen.bind(null, id, p_on_open);
@ -171,6 +180,11 @@ const GodotWebSocket = {
return GodotWebSocket.send(p_id, out);
},
godot_js_websocket_buffered_amount__sig: 'ii',
godot_js_websocket_buffered_amount: function (p_id) {
return GodotWebSocket.bufferedAmount(p_id);
},
godot_js_websocket_close__sig: 'viii',
godot_js_websocket_close: function (p_id, p_code, p_reason) {
const code = p_code;