endel / NativeWebSocket

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

Why close connection once message is sent? #15

Closed shiyuge closed 3 years ago

shiyuge commented 3 years ago

In Websocket.SendMessage we have:

var t = m_Socket.SendAsync(buffer, messageType, true, m_CancellationToken);

Because the third argument is true, this websocket client closes connection actively after message is sent.

What is the reason behind this design decision? In most use cases of websocket, I want a ongoing stream where I can repeatedly put my messages into, If I want the connection to be closed as soon as I get the message out, I would use http instead.

shiyuge commented 3 years ago

Sorry I understood it wrong. The third argument of SendAsync doesn't mean close connection after sending message