8000 Fixed: The callback "onMessageStr" is not properly adapted. by SONIC3D · Pull Request #31 · psygames/UnityWebSocket · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fixed: The callback "onMessageStr" is not properly adapted. #31

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 22, 2024
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
0