Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions Assets/UnityWebSocket/Plugins/WebGL/WebSocket.jslib
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ var WebSocketLibrary =
/* Event listeners */
onOpen: null,
onMessage: null,
onMessageStr: null,
onError: null,
onClose: null
},
Expand All @@ -46,7 +47,7 @@ var WebSocketLibrary =
},

/**
* Set onMessage callback
* Set onMessageStr callback
*
* @param callback Reference to C# static function
*/
Expand Down Expand Up @@ -106,9 +107,9 @@ var WebSocketLibrary =
if (!instance) return -1;

var protocol = UTF8ToString(protocolPtr);
if(instance.subProtocols == null)
instance.subProtocols = [];

if(instance.subProtocols == null)
instance.subProtocols = [];

instance.subProtocols.push(protocol);

Expand Down Expand Up @@ -137,7 +138,7 @@ var WebSocketLibrary =

return 0;
},

/**
* Connect WebSocket to the server
*
Expand Down Expand Up @@ -328,7 +329,7 @@ var WebSocketLibrary =
var instance = webSocketManager.instances[instanceId];
if (!instance) return -1;
if (instance.ws === null) return 3; // socket null as closed

return instance.ws.readyState;
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public static void DelegateOnMessageEvent(int instanceId, IntPtr msgPtr, int msg
}
}

[MonoPInvokeCallback(typeof(OnMessageCallback))]
[MonoPInvokeCallback(typeof(OnMessageStrCallback))]
public static void DelegateOnMessageStrEvent(int instanceId, IntPtr msgStrPtr)
{
if (sockets.TryGetValue(instanceId, out var socket))
Expand Down