Skip to content

Commit

Permalink
fix(SimpleWebTransport): Improve SimpleWeb.jslib to fit more platforms (
Browse files Browse the repository at this point in the history
#3904)

* fix: Improve SimpleWeb.jslib to fit more platforms

* fix: Improve SimpleWeb.jslib to fit more platforms

* Update Assets/Mirror/Transports/SimpleWeb/SimpleWeb/Client/Webgl/plugin/SimpleWeb.jslib

Co-authored-by: MrGadget <9826063+MrGadget1024@users.noreply.github.com>

* Update Assets/Mirror/Transports/SimpleWeb/SimpleWeb/Client/Webgl/plugin/SimpleWeb.jslib

Co-authored-by: MrGadget <9826063+MrGadget1024@users.noreply.github.com>

---------

Co-authored-by: “michaelwuwar” <“2443973716@qq.com”>
Co-authored-by: MrGadget <9826063+MrGadget1024@users.noreply.github.com>
  • Loading branch information
3 people authored Oct 1, 2024
1 parent 18bf67c commit 4261dd2
Showing 1 changed file with 10 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,23 +49,21 @@ function Connect(addressPtr, openCallbackPtr, closeCallBackPtr, messageCallbackP
const index = SimpleWeb.AddNextSocket(webSocket);

// Connection opened
webSocket.addEventListener('open', function (event)
webSocket.onopen = function(event)
{
console.log("Connected to " + address);
Runtime.dynCall('vi', openCallbackPtr, [index]);
});
webSocket.addEventListener('close', function (event)
};

webSocket.onclose = function(event)
{
console.log("Disconnected from " + address);
Runtime.dynCall('vi', closeCallBackPtr, [index]);
});
};

// Listen for messages
webSocket.addEventListener('message', function (event)
webSocket.onmessage = function(event)
{
if (event.data instanceof ArrayBuffer)
{
// TODO dont alloc each time
if (event.data instanceof ArrayBuffer) {
var array = new Uint8Array(event.data);
var arrayLength = array.length;

Expand All @@ -80,13 +78,13 @@ function Connect(addressPtr, openCallbackPtr, closeCallBackPtr, messageCallbackP
{
console.error("message type not supported")
}
});
};

webSocket.addEventListener('error', function (event)
webSocket.onerror = function(event)
{
console.error('Socket Error', event);
Runtime.dynCall('vi', errorCallbackPtr, [index]);
});
};

return index;
}
Expand Down

0 comments on commit 4261dd2

Please sign in to comment.