|
@@ -17,21 +17,23 @@ namespace WebSocket {
|
|
|
// Note : The websocket protocol is defined by RFC 6455, found at https://tools.ietf.org/html/rfc6455
|
|
|
// In this file, section numbers will refer to the RFC 6455
|
|
|
|
|
|
-NonnullRefPtr<WebSocket> WebSocket::create(ConnectionInfo connection)
|
|
|
+NonnullRefPtr<WebSocket> WebSocket::create(ConnectionInfo connection, RefPtr<WebSocketImpl> impl)
|
|
|
{
|
|
|
- return adopt_ref(*new WebSocket(move(connection)));
|
|
|
+ return adopt_ref(*new WebSocket(move(connection), move(impl)));
|
|
|
}
|
|
|
|
|
|
-WebSocket::WebSocket(ConnectionInfo connection)
|
|
|
+WebSocket::WebSocket(ConnectionInfo connection, RefPtr<WebSocketImpl> impl)
|
|
|
: m_connection(move(connection))
|
|
|
+ , m_impl(move(impl))
|
|
|
{
|
|
|
}
|
|
|
|
|
|
void WebSocket::start()
|
|
|
{
|
|
|
VERIFY(m_state == WebSocket::InternalState::NotStarted);
|
|
|
- VERIFY(!m_impl);
|
|
|
- m_impl = adopt_ref(*new WebSocketImplSerenity);
|
|
|
+
|
|
|
+ if (!m_impl)
|
|
|
+ m_impl = adopt_ref(*new WebSocketImplSerenity);
|
|
|
|
|
|
m_impl->on_connection_error = [this] {
|
|
|
dbgln("WebSocket: Connection error (underlying socket)");
|