endel / NativeWebSocket

🔌 WebSocket client for Unity - with no external dependencies (WebGL, Native, Android, iOS, UWP)
Other
1.13k stars 155 forks source link

Are we able to send or react to ping/pong message? #94

Open zouh520sdo opened 3 months ago

zouh520sdo commented 3 months ago

I'm using the NativeWebSocket in Unity for my client. Things are working fine for me except for I don't find a way to send or react to ping/pong message for web socket. Is it supported by NativeWebSocket?

endel commented 3 months ago

Hi @zouh520sdo, as far as I know, it is not possible to interact with PING/PONG frames from the native System.Net.WebSockets. However, the underlying client handles them automatically https://github.com/dotnet/runtime/blob/dc9c9d5f9e23ff6aa0b99af8f6c410a0558fadaf/src/libraries/System.Net.WebSockets/src/System/Net/WebSockets/ManagedWebSocket.cs#L777-L781

mikerochip commented 2 months ago

I'm using the NativeWebSocket in Unity for my client. Things are working fine for me except for I don't find a way to send or react to ping/pong message for web socket. Is it supported by NativeWebSocket?

@zouh520sdo If you want ping pong support and you want it to work on all platforms, try this instead https://github.com/mikerochip/unity-websocket?tab=readme-ov-file#customizable-ping-pong-support

You will need to customize your server to ignore the messages though