close with params

This commit is contained in:
Benjamin Sergeant
2019-05-01 11:29:50 -07:00
parent 14ec8522ef
commit d93f723e68
5 changed files with 417 additions and 4 deletions

View File

@ -216,9 +216,10 @@ namespace ix
return getReadyState() == WebSocket_ReadyState_Closing;
}
void WebSocket::close()
void WebSocket::close(uint16_t code,
const std::string& reason)
{
_ws.close();
_ws.close(code, reason);
}
void WebSocket::reconnectPerpetuallyIfDisconnected()

View File

@ -111,7 +111,11 @@ namespace ix
WebSocketSendInfo sendText(const std::string& text,
const OnProgressCallback& onProgressCallback = nullptr);
WebSocketSendInfo ping(const std::string& text);
void close();
// A close frame can provide a code and a reason
// FIXME: use constants
void close(uint16_t code = 1000,
const std::string& reason = "Normal closure");
void setOnMessageCallback(const OnMessageCallback& callback);
static void setTrafficTrackerCallback(const OnTrafficTrackerCallback& callback);