mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-17 18:40:33 +00:00
fix(SimpleWebTransport): Improve SimpleWeb.jslib to fit more platforms (#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>
This commit is contained in:
parent
18bf67c007
commit
4261dd2189
@ -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;
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user