Knowledge about ngtcp2 is moved down into the state machine

This commit is contained in:
Mark Spanbroek 2021-06-09 17:30:26 +02:00 committed by markspanbroek
parent 49016fff3c
commit 84f080b75b
2 changed files with 11 additions and 8 deletions

View File

@ -7,6 +7,8 @@ import ../../connectionid
import ../../stream
import ../native/connection
import ../native/streams
import ../native/client
import ../native/server
import ./closingstate
import ./drainingstate
import ./disconnectingstate
@ -19,6 +21,13 @@ type
proc newOpenConnection*(ngtcp2Connection: Ngtcp2Connection): OpenConnection =
OpenConnection(ngtcp2Connection: ngtcp2Connection)
proc openClientConnection*(local, remote: TransportAddress): OpenConnection =
newOpenConnection(newNgtcp2Client(local, remote))
proc openServerConnection*(local, remote: TransportAddress,
datagram: Datagram): OpenConnection =
newOpenConnection(newNgtcp2Server(local, remote, datagram.data))
{.push locks: "unknown".}
method enter(state: OpenConnection, connection: QuicConnection) =

View File

@ -1,17 +1,11 @@
import pkg/chronos
import ../udp/datagram
import ./quicconnection
import ./ngtcp2/native
import ./ngtcp2/connection/openstate
proc newConnection(ngtcp2Connection: Ngtcp2Connection): QuicConnection =
let state = newOpenConnection(ngtcp2Connection)
let connection = newQuicConnection(state)
connection
proc newQuicClientConnection*(local, remote: TransportAddress): QuicConnection =
newConnection(newNgtcp2Client(local, remote))
newQuicConnection(openClientConnection(local, remote))
proc newQuicServerConnection*(local, remote: TransportAddress,
datagram: Datagram): QuicConnection =
newConnection(newNgtcp2Server(local, remote, datagram.data))
newQuicConnection(openServerConnection(local, remote, datagram))