1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-10 13:00:37 +00:00

[HTML5] Add function signatures to JS libraries.

This commit is contained in:
Fabio Alessandrelli
2020-12-03 12:51:17 +01:00
parent 9df3d06d1f
commit 8ebb52fad6
10 changed files with 84 additions and 3 deletions

View File

@@ -135,6 +135,7 @@ const GodotWebSocket = {
},
},
godot_js_websocket_create__sig: 'iiiiiiii',
godot_js_websocket_create: function (p_ref, p_url, p_proto, p_on_open, p_on_message, p_on_error, p_on_close) {
const on_open = GodotRuntime.get_func(p_on_open).bind(null, p_ref);
const on_message = GodotRuntime.get_func(p_on_message).bind(null, p_ref);
@@ -156,6 +157,7 @@ const GodotWebSocket = {
return GodotWebSocket.create(socket, on_open, on_message, on_error, on_close);
},
godot_js_websocket_send__sig: 'iiiii',
godot_js_websocket_send: function (p_id, p_buf, p_buf_len, p_raw) {
const bytes_array = new Uint8Array(p_buf_len);
let i = 0;
@@ -169,12 +171,14 @@ const GodotWebSocket = {
return GodotWebSocket.send(p_id, out);
},
godot_js_websocket_close__sig: 'viii',
godot_js_websocket_close: function (p_id, p_code, p_reason) {
const code = p_code;
const reason = GodotRuntime.parseString(p_reason);
GodotWebSocket.close(p_id, code, reason);
},
godot_js_websocket_destroy__sig: 'vi',
godot_js_websocket_destroy: function (p_id) {
GodotWebSocket.destroy(p_id);
},