From 0e9f6f183b8d010a1e6f05e31db50d34f383c85b Mon Sep 17 00:00:00 2001 From: m000z0rz Date: Wed, 17 Jun 2020 18:41:49 -0500 Subject: [PATCH] Allow undefined (optional) callbacks for Socket.connect and Socket.write --- Source/Project64/UserInterface/API.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Source/Project64/UserInterface/API.js b/Source/Project64/UserInterface/API.js index b3dd82531..3e90a46ea 100644 --- a/Source/Project64/UserInterface/API.js +++ b/Source/Project64/UserInterface/API.js @@ -51,6 +51,7 @@ const _gprNames = [ // to them in Javascript so they don't get garbage collected before native code uses them. const _strongBackingReferences = (function() { const _references = []; + const noop = function () { }; return { "add": function _strongBackingReferences_add(obj) @@ -67,6 +68,11 @@ const _strongBackingReferences = (function() { }, "singleUseCallback": function _strongBackingReferences_singleUseCallback(callback) { + if (callback === undefined) + { + return noop; + } + const singleUseCallback = function () { callback.apply(undefined, arguments); @@ -896,7 +902,10 @@ function Socket(fd) var _onconnect_base = function(){ connected = 1; - _onconnect(); + if (_onconnect !== undefined) + { + _onconnect(); + } } var _bufferSize = 2048