mirror of https://github.com/vacp2p/nim-quic.git
Knowledge about ngtcp2 is moved down into the state machine
This commit is contained in:
parent
49016fff3c
commit
84f080b75b
|
@ -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) =
|
||||
|
|
|
@ -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))
|
||||
|
|
Loading…
Reference in New Issue